Re: Re: best way to properly build an include path *regardless* from where I am calling the include?
| From: | Michael A. Peters | Date: | Sun, 05 Jul 2009 22:17:52 +0000 |
| Subject: | Re: Re: best way to properly build an include path *regardless* from where I am calling the include? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-294905@lists.php.net to get a copy of this message | ||
Govinda wrote:
in my include statement, I am now successfully using: /home/metheuser/public_html/ and am not anticipating moving this site.. but still I am thinking there must be a way to make the code bullet proof to dir/ name changes *after* the virtual server root. Or do people just stop here?I always define the include path explicitly, and it never includes anything inside the web root, but that's just me. I use $includeArray[]="/usr/share/pear"; $includeArray[]="/some/other/path"; $includeArray[]="/yet/another/path"; $incPath = impode(':',$includeArray); ini_set("include_path",$incPath); Since all my includes are external to the website where they don't ever need to moved no matter how I decide to change things, their paths never move. Served files inside the web root however can move around freely and always find their includes. I admit, keeping all excludes outside the web root can be a bit tedious, but it helps keeps things well organized. There's more than one way to do it though.