PHP code in HTML file

Discussion in 'HTML & Website Design' started by annvijay, Jul 25, 2008.

  1. #1
    Hi,
    I am new to php and html. Here my question Is there possible to have PHP code in .html file like these

    I created a test file and filename it test.html


    <html>
    <head></head>
    <body>
    <h1>
    <?php echo "I LOVE PHP!"; ?>
    </h1>
    </body>
    </html>

    When I execute this test.html file its not working means not executing the php code.Is it possible to execute these file.
    If it is not possible Why?

    thanks
     
    annvijay, Jul 25, 2008 IP
  2. Spawny

    Spawny Well-Known Member

    Messages:
    252
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    110
    #2
    html cant execute php save it instead as test.php ^^
     
    Spawny, Jul 25, 2008 IP
  3. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #3
    You CAN parse php in html files by fiddling around with htaccess.
    One of the first results in Googs: http://www.desilva.biz/php/phpinhtml.html

    But if you're just starting out with php, just use the php extension.
     
    Kerosene, Jul 25, 2008 IP