Currently I'm naming all my include files with the .php extension, but I heard this was bad practice as they will be parsed as individual scripts when they're not meant to be.

.inc files should be used, and I heard the safest way to use them would be to put them in a directory outside htdocs and change the include path in the php.ini file. However, I don't have access to that.

Is there any other way I can change the default include path?

    Try a relative path when including.
    include '../include/file.inc';

    Also, if you're afraid or your includes parsing as individual scripts, you could put some kind of check at the top of the script that kills it if called directly.
    Saves you the trouble of renaming.

    // kill if called directly
    if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) exit;

      I'm trying to avoid relative paths as they can be hassle and it's not so much as them parsing as individual scripts, it's security really.

      Is there something I can add into .htaccess?

        Write a Reply...