php include in yahoo

this tip applies to those who what to use php in their yahoo webhosting package.

you can put the php include files in the root subdirectory (.) which would makes things a bit messy in the long run. to keep things organized create an subdirectory named “include” from the root directory. this is where your included php files will be uploaded. this directory is included in the php include_path directive by default but is not mentioned in the help files or created during setup.

if you want to include, for example, myheaders.php from another php file, say, index.php, upload myheaders.php to the /include subdirectory and within the index.php file after the starting body tag type in:

< ?php include "myheaders.php" ?>

please note that there shouldn’t be any space between the “less than” character and the question mark — its a wordpress thing.

by putting the files to be included in the include subdirectory, you can add that bit of code above from any file in any subdirectory within your site and its going to be included — there is no need for a full path name. of course, you have to use your own filename. ;)

important security note: add a blank index.php file in every subdirectory that doesn’t have any index.php or index.html file. this will prevent anyone from getting a list of the directory contents. what they will see is just a blank page.

comments are closed.