note 87448 deleted from function.set-include-path by danbrown
| From: | danbrown@php.net | Date: | Fri, 05 Dec 2008 13:33:22 +0000 |
| Subject: | note 87448 deleted from function.set-include-path by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147686@lists.php.net to get a copy of this message | ||
Note Submitter: stevet
----
Thanks Ricardo, just what I was looking for, although it could be refined a little:
<?php
function add_include_path($path) {
$paths = explode(PATH_SEPARATOR, get_include_path()) ; // get existing paths once
foreach (func_get_args() as $path) {
if (!file_exists($path) OR (file_exists($path) && filetype($path) !== 'dir')) {
trigger_error("Include path '{$path}' does not exist", E_USER_WARNING);
continue;
}
$paths[] = $path ; // just add them all
}
$paths = array_flip(array_flip($path)) ; // remove duplicates
set_include_path(implode(PATH_SEPARATOR, $paths)); // set all paths just once
}
?>