Grow your CSS skills. Land your dream job.

PHP Include problem

  • # July 4, 2013 at 6:05 pm

    Hi,

    I’m 99.5% new to PHP, but I’ve done some coding in other languages. I inherited this website and it has a few HTML files in it with some form of include syntax that includes a .php file into the page.

    Since the file (home.html) has an .html extension I’m confused on how it is able to include a php file within it with the code below?

    < ? include("header.php");?>

    Can someone why this code possibly works or if there was something special needed to get an html file to include some php file?

    I copied the code over to my machine and it when I run it, it doesn’t process the header.php file unless I rename the HTML file to home.php, but the site seems to work fine where the code previously was if that makes sense.

    # July 4, 2013 at 6:09 pm

    I’m 99% sure this is an .htaccess thing that allows different file extensions to handle PHP functions. Somebody else can certainly speak a little more clearly on the topic, I’m far from an .htaccess expert!

    # July 4, 2013 at 6:22 pm

    Apache is treating all `.html` requests as `.php` request. And is able to process the PHP code. @TheDoc is right, 99% chance it’s .htaccess file.

    # July 4, 2013 at 6:35 pm

    Ok, thanks…

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".