note 83186 deleted from function.include by peehaa

From: Date: Fri, 09 Dec 2016 22:47:45 +0000
Subject: note 83186 deleted from function.include by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208387@lists.php.net to get a copy of this message
Note Submitter: ricardo dot ferro at gmail dot com ---- Two functions to help: <?php function add_include_path ($path) { foreach (func_get_args() AS $path) { if (!file_exists($path) OR (file_exists($path) && filetype($path) !== 'dir')) { trigger_error("Include path '{$path}' not exists", E_USER_WARNING); continue; } $paths = explode(PATH_SEPARATOR, get_include_path()); if (array_search($path, $paths) === false) array_push($paths, $path); set_include_path(implode(PATH_SEPARATOR, $paths)); } } function remove_include_path ($path) { foreach (func_get_args() AS $path) { $paths = explode(PATH_SEPARATOR, get_include_path()); if (($k = array_search($path, $paths)) !== false) unset($paths[$k]); else continue; if (!count($paths)) { trigger_error("Include path '{$path}' can not be removed because it is the only", E_USER_NOTICE); continue; } set_include_path(implode(PATH_SEPARATOR, $paths)); } } ?>

« previous php.notes (#208387) next »