How can i add a PHP script code on a HTML page?

Discussion in 'HTML & Website Design' started by TheSyndicate, Oct 25, 2011.

  1. #1
    How can i add a PHP script code on a HTML page?
    the html is a template file.
     
    TheSyndicate, Oct 25, 2011 IP
  2. itpixelz

    itpixelz Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can add php script at any where in html just adding php tags
    <h1>Heading</h1>
    <?php ..script... ?>
    <p>this is para</p>
     
    itpixelz, Oct 25, 2011 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    If the file is named something.html, it won;'t run PHP code. You'll have to rename it to something.php.

    Since this is a template, not an HTML file, you can't do it that way. Most templating systems don't allow PHP in the template, so you'd have to write a plugin for the system or redesign the program that's using the templating system in order to be able to put PHP in templates. And how to do that is really beyond the scope of this forum.
     
    Rukbat, Oct 25, 2011 IP
  4. Xaa_Zen

    Xaa_Zen Member

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #4
    If you don't change your document's file name from "index.html" into "index.php" your script will not work. So don't forget it.
     
    Xaa_Zen, Oct 25, 2011 IP
  5. Tedel

    Tedel Well-Known Member

    Messages:
    326
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    130
    #5
    There is an option, though. You can configure your .htaccess file so that it will ask the computer to process/parse html files as php files, if necessary. A search online will help you find how.
     
    Tedel, Oct 25, 2011 IP
  6. hostgladiator

    hostgladiator Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The easiest way is to just change you file name to a php extension.
     
    hostgladiator, Oct 25, 2011 IP
  7. mishayr

    mishayr Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    you can use Frame tool
     
    mishayr, Oct 26, 2011 IP
  8. browntwn

    browntwn Illustrious Member

    Messages:
    8,347
    Likes Received:
    848
    Best Answers:
    7
    Trophy Points:
    435
    #8
    browntwn, Oct 26, 2011 IP
  9. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #9
    So if i change my .htaccess i can run php code in a html file?
     
    TheSyndicate, Oct 27, 2011 IP