note 103915 deleted from function.set-include-path by danbrown

From: Date: Wed, 11 May 2011 15:43:29 +0000
Subject: note 103915 deleted from function.set-include-path by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179622@lists.php.net to get a copy of this message
Note Submitter: gruessle @ google mail ---- <?php /** * Description Add a directory to the php include path * * @package TaMeR * @category File * @type Function * @author Dennis T Kaplan * @copyright (C) 2009-2011 Dennis T Kaplan * @license GPL {@link http://www.gnu.org/licenses/gpl.html} * @todo * * @param dir: The directory to add to the path * @param at_end: If true, place this directory at the end of * the include path. Otherwise, place it at the beginning. */ function addInclude($dir, $at_end = false) { $exist = file_exists($dir); if ( ! $exist || ($exist && filetype($dir) != 'dir')) { trigger_error("Include path '{$dir}' does not exist", E_USER_WARNING); echo '<pre>'; print_r(debug_backtrace()); exit; } $dir = rtrim($dir, "/"); $paths = ltrim(get_include_path(), ".".PATH_SEPARATOR); $paths = explode(PATH_SEPARATOR, $paths); $ds = '.'.PATH_SEPARATOR; if (strlen($paths[0]) && array_search($dir, $paths) === false) { $at_end ? array_push($paths, $dir) : array_unshift($paths, $dir); $paths = implode(PATH_SEPARATOR, $paths); set_include_path($ds.$paths); } else { set_include_path($ds.$dir); } } /* #Test it echo get_include_path(); echo '<br />'; addInclude('/var/www/library/'); echo get_include_path(); echo '<br />'; */ ?>

« previous php.notes (#179622) next »