How do I include PHP into an HTML file?

Discussion in 'PHP' started by praisehim, May 2, 2008.

  1. #1
    Good day all,

    I'm a complete newbie to PHP. I mostly do HTML, but right now I am working on a project that requires the use of both. Is it possible to include PHP into a HTML document and have it still run at PHP?

    What I mean is, I know that you can have HTML in a .php file, but can you have PHP in a .html file? If not what is the best solution to this problem. I would like to have them both co-exist with each other so that I can get the best of both worlds.

    Mostly what I would be including in the end result is <?php echo> where the PHP will echo information from another file into the present file, if that makes sense. :confused:

    Thanks in advance
     
    praisehim, May 2, 2008 IP
  2. lock

    lock Banned

    Messages:
    205
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think you will be ok just to embed the code into the html document.
     
    lock, May 2, 2008 IP
  3. 007c

    007c Peon

    Messages:
    611
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Just rename file php and start the doc with the <?php tag and use ?> for end and <? start of php throughout the doc. for ex
    <?php
    sum variables or includes
    ?>
    sum html here for header
    <? if (sumthin =sumthin) {?>
    sum reg html here
    <?}?>
    some more html here etc...
    <? echo "whohoo"; /*add newlines if needed*/
    ?>
     
    007c, May 2, 2008 IP