Using set_include_path () (or ini_set ('include_path', ...)) allows you to specify several folders that will contain your library code. For example, if your application relies on many different frameworks / libraries, for example. PEAR and Zend FW, you might have something like
ini_set ('include_path', '/ usr / local / php / pear: / usr / local / php / zendfw');
The disadvantage of this approach is that it will use any file that it finds first; if you have a file called "Mailer.php" in more than one of your included paths, it will include the first one found, causing subtle errors if that is not your intention. Good code organization usually solves this problem. In addition, include_path goes through the cache of the real path ( http://us2.php.net/realpath ), which sometimes needs to be tuned to improve performance depending on your configuration.
Both methods are good, but using the define () method is more explicit.
FWIW, I usually use ini_set ('include_path', ...).
Michael
source share