Posted By

trey on 07/15/08


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


PHP Include Path

 / Published in: PHP

If you're using includes that sit in different relative locations to the files your including into, you normally end up with stuff like include("../../header.php") in one place and include("../../../header.php") in another. This is a bit easier, but be sure to include a leading /, because depending on your sever configuration, it may or may not add one for you. It's better to have 2 /s than none.

  1. <?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/whatever.php"); ?>

Report this snippet  


RSS Icon Subscribe to comments
Posted By: jonhenshaw on July 15, 2008

This include is so much better than the ../../ I've been using. I'm sure to most experienced coders this is old news, but for me, this is awesome.

You need to login to post a comment.