Page 1 of 1
include_path
Posted: Fri Jul 27, 2007 11:27 am
by guitarlvr
my include_path in php.ini is set to include the PEAR directory which i imagine is pretty standard. My question is, what exactly does it do? how do i include classes that are inside the PEAR directory in my .php pages?
Posted: Fri Jul 27, 2007 11:47 am
by miro_igov
You can directly
instead of
Posted: Fri Jul 27, 2007 1:05 pm
by guitarlvr
That's pretty sweet. is that where most developers put libraries such as swiftmailer, template lite, html purifier, etc?
Posted: Fri Jul 27, 2007 2:40 pm
by superdezign
I prefer not to rely on anything that's set in php.ini because not every php.ini is the same. I specify the path an file in relation to the current file using dirname(__FILE__) for every file that I include.
Posted: Sat Jul 28, 2007 4:32 pm
by feyd
Posted: Sun Jul 29, 2007 4:34 am
by miro_igov
guitarlvr wrote:That's pretty sweet. is that where most developers put libraries such as swiftmailer, template lite, html purifier, etc?
But if you have multiple include paths and for some reason there are files with same names i wonder which one will be included

Posted: Sun Jul 29, 2007 8:37 am
by superdezign
guitarlvr wrote:That's pretty sweet. is that where most developers put libraries such as swiftmailer, template lite, html purifier, etc?
I don't know.. I've never checked. Swiftmailer is so well put together, I get lost in amazement every time that I read the code. HTML Purifier is a lot easier to follow, but I'm a bit more familiar with HTML and lexers than anything e-mail related.
I hope they did, though. I've ran into problems where PHP isn't exactly sure which folder I'm referring to without the absolute path of __FILE__.
Posted: Sun Jul 29, 2007 4:24 pm
by timvw
miro_igov wrote:
But if you have multiple include paths and for some reason there are files with same names i wonder which one will be included

The answer is pretty simple: the first one it finds. (this and the order of searching is somewhere in the documentation, but i can't find it right now)
(Aha, i found it:
http://be2.php.net/manual/en/function.include.php)
Files for including are first looked in include_path relative to the current working directory and then in the directory of the current script. E.g. if your include_path is libraries, current working directory is /www/, you included include/a.php and there is include "b.php" in that file, b.php is first looked in /www/libraries/ and then in /www/include/. If filename begins with ./ or ../, it is looked only in include_path relative to the current working directory.