1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Is it possible to add PHP code to a .html page?

Discussion in 'PHP' started by AfterHim.com, Jan 21, 2006.

  1. #1
    Is it possible to add PHP code to a .html page?

    If so, can you give me a tutorial?

    Thanks,

    brandon
     
    AfterHim.com, Jan 21, 2006 IP
  2. allthewhile

    allthewhile Peon

    Messages:
    118
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    just rename the .html page to .php

    that's the only way!

    Good luck!
     
    allthewhile, Jan 21, 2006 IP
    AfterHim.com likes this.
  3. Smyrl

    Smyrl Tomato Republic Staff

    Messages:
    13,740
    Likes Received:
    1,702
    Best Answers:
    78
    Trophy Points:
    510
    #3
    It is possible to do so. My guru supplies me the code so can not provide tutorial.

    Shannon
     
    Smyrl, Jan 21, 2006 IP
    AfterHim.com likes this.
  4. allthewhile

    allthewhile Peon

    Messages:
    118
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Are you restricted from changing the filename? The php on your server can't parse it as php unless the filename is .php

    I do believe Shannon is incorrect but I could be wrong.
     
    allthewhile, Jan 21, 2006 IP
  5. AfterHim.com

    AfterHim.com Peon

    Messages:
    1,923
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The only downside is that google would have to reindex all of the new pages...and all the links would have to be changed...the site is over 100,000 pages of dynamically created, but now static content.
     
    AfterHim.com, Jan 21, 2006 IP
  6. Smyrl

    Smyrl Tomato Republic Staff

    Messages:
    13,740
    Likes Received:
    1,702
    Best Answers:
    78
    Trophy Points:
    510
    #6
    I added some php to an html page this last week and the beauty is when someone views the source it does not show the php.

    Shannon
     
    Smyrl, Jan 21, 2006 IP
  7. allthewhile

    allthewhile Peon

    Messages:
    118
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Php is executed on the server side. The php is never shown. For example, my personal site is a php powered wordpress site:

    http://www.franklinfamily.org

    You won't see a lick of php code.
     
    allthewhile, Jan 21, 2006 IP
    mazhi likes this.
  8. goodtimetribe

    goodtimetribe Peon

    Messages:
    53
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    This is incorrect. You can if you tell your web server software to do so.

    in apache http.conf modify/add:

    # For PHP 5 do something like this:
    LoadModule php5_module "c:/php/php5apache2.dll"
    AddType application/x-httpd-php .php .html .htm
    
    Code (markup):
    I just tested this for functionality and it works 100%
     
    goodtimetribe, Jan 21, 2006 IP
  9. fsmedia

    fsmedia Prominent Member

    Messages:
    5,163
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #9
    You don't have to do this strictly in the http.conf though; if the config allows for it -- you could do it in the .htaccess file as well.
     
    fsmedia, Jan 21, 2006 IP
    AfterHim.com likes this.
  10. AfterHim.com

    AfterHim.com Peon

    Messages:
    1,923
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #10
    allthewhile,

    The problem is that all of the pages are already .html and they need to stay that way.

    is there a way to implement a snippet of php code into a .html page?
     
    AfterHim.com, Jan 21, 2006 IP
  11. AfterHim.com

    AfterHim.com Peon

    Messages:
    1,923
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #11
    so if i added this:

    to my .htaccess I should be able to just put the php code in?

    Thanks for all the help
     
    AfterHim.com, Jan 21, 2006 IP
  12. GetWebHost

    GetWebHost Active Member

    Messages:
    735
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    78
    #12
    Absoulutely YES because you instruct it to parse html pages as PHP also and any PHP code you put in that html page will be parse now :)
     
    GetWebHost, Jan 22, 2006 IP
    AfterHim.com likes this.
  13. goodtimetribe

    goodtimetribe Peon

    Messages:
    53
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Yup, this is probably the easiest way without renaming all the files or modifying the code in any other fashion.
     
    goodtimetribe, Jan 23, 2006 IP
    AfterHim.com likes this.
  14. Amos

    Amos Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #14
    You could use mod_rewrite and redirect all the pages to a php page.
     
    Amos, Jan 23, 2006 IP
    AfterHim.com likes this.
  15. AfterHim.com

    AfterHim.com Peon

    Messages:
    1,923
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Thanks everyone!

    Used this code:

    And now my site parses PHP on ever .html page.

    Thanks!

    brandon
     
    AfterHim.com, Jan 24, 2006 IP
  16. GetWebHost

    GetWebHost Active Member

    Messages:
    735
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    78
    #16
    Congrats :)
     
    GetWebHost, Jan 24, 2006 IP
  17. picos

    picos Active Member

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #17
    where can u change it ???
     
    picos, Sep 1, 2009 IP
  18. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #18
    Paste that in .htaccess file.

    With .htaccess you can even parse haha.lol as PHP. :D
     
    ads2help, Sep 2, 2009 IP
  19. zmanblog

    zmanblog Active Member

    Messages:
    180
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    60
    #19
    I have a HTML site/page and I need to add a Google Adsense Mobile Content ad. How can I go about doing that because the ad code is PHP, and instead of displaying the ad it displays the code....
     
    zmanblog, Nov 6, 2011 IP
  20. MakZF

    MakZF Well-Known Member

    Messages:
    390
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    140
    #20
    the htaccess way is easy, though if you have access to your server's config files you can change which file extensions are classed as php files in the MIME types file.
     
    MakZF, Nov 9, 2011 IP