Simple PHP Include isn't working ~


Hey Folks,

I’m reasonably familiar with HTML, and brand new to PHP.

For now, I’m just wanting to use the PHP “include” function, but it doesn’t seem to be working.

Here’s a simple example of the problem:

using <?php include("includes/test.php"); ?>

Dreamhost support recommended I use that exact formatting, featuring the relative URL, but I’ve also tested absolute URLs as well as single ’ instead of double "

You can see them all fail here:

Any thoughts?



Since you’re “brand new” I’m going to assume you are on shared hosting and haven’t attempted to use the .htaccess or phprc files yet.

First of all, its not going to work in a file with the extension .html - you need to rename the files to have extension .php

Second, using include() with a URL is bad, so it is disabled. Instead of a URL, use a file system path to a local file instead. And having said that, you may need to specify the full path, i.e. /home/USERNAME/ - also see the $_SERVER[‘DOCUMENT_ROOT’] value.


Ok, I tried it with test.php instead of .html, and now it works.

Is there no way to use php includes within a .html file?

Ah, got it, had to add this line to .htaccess:

AddType application/x-httpd-php5 .htm .html .php