note 90340 added to function.include

From: Date: Fri, 17 Apr 2009 00:01:16 +0000
Subject: note 90340 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-153413@lists.php.net to get a copy of this message
After lots of research, I've found this is the most useful way of accessing a folder of include files at the root of a website from any page.. I simply add this line at the top of each of my .php pages: <? ini_set("include_path", "." .PATH_SEPARATOR. "../" .PATH_SEPARATOR. "../../" .PATH_SEPARATOR. "../../../"); ?> This configures the include_path directive to look for include files up to 3 folders *above* the current file Note: Using the PATH_SEPARATOR constant instead of ";" or ":" covers both Windows & Unix php installations. Also keep in mind that if some of your pages are any deeper than 3 folders, you will need to add more paths.. Then any include statements (where includes are kept in a folder called "includes" at the root) look like this: <? include("includes/header.inc.php"); ?> Hope this helps! - gabe m ---- Server IP: 66.207.199.35 Probable Submitter: 24.82.171.23 ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- https://master.php.net/note/edit/90340 Del: integrated -- https://master.php.net/note/delete/90340/integrated Del: useless -- https://master.php.net/note/delete/90340/useless Del: bad code -- https://master.php.net/note/delete/90340/bad+code Del: spam -- https://master.php.net/note/delete/90340/spam Del: non-english -- https://master.php.net/note/delete/90340/non-english Del: in docs -- https://master.php.net/note/delete/90340/in+docs Del: other reasons-- https://master.php.net/note/delete/90340 Reject -- https://master.php.net/note/reject/90340 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153413) next »