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.

Display PHP in a .html file?

Discussion in 'Site & Server Administration' started by Max Powers, Oct 6, 2005.

  1. #1
    May seem like a stupid question but:

    I want to display an RSS feed on my website. I know that my host provides .htacess and supports php. But when I paste a php code into an html file it just turns up with garbage when I put it online :confused: ?

    Help MUCH appreciated
     
    Max Powers, Oct 6, 2005 IP
  2. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #2
    PHP needs to be executed by the PHP program installed on the server. HTML code is just read, interpreted, and displayed. (I'm simplifying things a little.)

    Therefore you can put HTML code inside a PHP file, however you cannot put PHP code inside an HTML file. As you noticed the PHP code will not execute because the server thinks it is a plain old HTML file.

    Without looking at exactly what you are doing you might be able to rename your HTML file with a .php extension instead of the html extension, put the PHP code inside it and be okay.
     
    tflight, Oct 6, 2005 IP
  3. JoeO

    JoeO Peon

    Messages:
    431
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #3
    add this line to your .htaccess file:

    AddType application/x-httpd-php .html .php
     
    JoeO, Oct 6, 2005 IP
  4. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That will work too, but it will also cause all html files to be executed by PHP even if they don't have any PHP code in them. It would create unnecessary processing time.
     
    tflight, Oct 6, 2005 IP
  5. Max Powers

    Max Powers Peon

    Messages:
    56
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ah thanks for help dudes :)
     
    Max Powers, Oct 6, 2005 IP