Very Simple PHP question

Discussion in 'PHP' started by ketting00, Sep 27, 2010.

  1. #1
    Hi,

    I have no problem with PHP file, but I just wonder why this simple tag does not work in html file:

    <?php echo "It Works!"; ?>

    Why? I've search on Goole and there's no solution.

    The reason I want to know about this is because I want o migrate my all PHP-powered site into html.

    Thanks for your help in advance
     
    ketting00, Sep 27, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    Its because your extension is .html and not .php, however you can tell your server to phrase html files like as if it was a php file.

    To do that you need to create or add to a .htaccess file and place the following into it.
    
    AddType application/x-httpd-php .html .htm
    
    Code (markup):
    or for php5 use this
    
    AddType application/x-httpd-php5 .html .htm
    
    Code (markup):
     
    MyVodaFone, Sep 27, 2010 IP
  3. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #3
    thanks for the answer, I'll start learning about this .htaccess trick right away.
     
    ketting00, Sep 27, 2010 IP
  4. jocurileus

    jocurileus Peon

    Messages:
    53
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That's not really migrating to html, it just interprets html as php files...
     
    jocurileus, Sep 27, 2010 IP
  5. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #5
    It's a big heap of headach. I added .htaccess file and it didn't work.
    Anyway, I want to re-design my website in html5 with PHP backup, anyone has suggestions about this?

    Thanks
     
    ketting00, Sep 27, 2010 IP
  6. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #6
    Try instead
    
    AddHandler application/x-httpd-php .html .htm 
    
    Code (markup):
    or for php 5
    
    AddHandler application/x-httpd-php5 .html .htm 
    
    Code (markup):
     
    MyVodaFone, Sep 27, 2010 IP
  7. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
  8. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #8
    There's no reason for it not to work, remember if your server is running php 5 then you need to amend your .htaccess file to application/x-httpd-php5
     
    MyVodaFone, Sep 27, 2010 IP
  9. jocurileus

    jocurileus Peon

    Messages:
    53
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    @ketting00 do you mean you want a design complied with html5 powered by php?
    You know that php != html right?
    If you want an all html website, then you have to do a new html page for everything, you know that, right ? :)
     
    jocurileus, Sep 28, 2010 IP