Re: "include()" Function Policy Question

From: Date: Fri, 18 Apr 2003 23:11:43 +0000
Subject: Re: "include()" Function Policy Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-144446@lists.php.net to get a copy of this message
Hi David, include() is documented at http://www.php.net/manual/en/function.include.php The good news is that include() is very flexible, and will work with relative paths (PEAR makes use of this). You do take a risk. If the include_path config file parameter finds another file of the same name in another location, that will be included. To solve this problem, you can simulate relative path inclusion using dirname(__FILE__) to retrieve the absolute path of the running file. Then, include(dirname(__FILE__) . 'my_sub_path/my_include_file.inc'); will be more likely to work. This only matters in situations where you will not have control over where files are placed (i.e. you are distributing your code). Regards, Greg -- phpDocumentor http://www.phpdoc.org David T. Ashley wrote:
Hi, I have a question that can't be resolved satisfactorily elsewhere. I would like to use include() function invocations of the form: include("my_sub_path/my_include_file.inc"); In other words, I'd like to organize my include files a bit within the include directory. I could find no mention of this in the documentation. a)Is this supported (will it work now)? b)Is this supported as a matter of policy (will it work in the future)? Thanks, Dave Ashley.


« previous php.general (#144446) next »