note 103915 added to function.set-include-path

From: Date: Wed, 11 May 2011 07:06:48 +0000
Subject: note 103915 added to function.set-include-path
Groups: php.notes 
Request: Send a blank email to php-notes+get-179591@lists.php.net to get a copy of this message
<?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 />'; */ ?> ---- Server IP: 192.41.42.26 Probable Submitter: 108.77.16.164 ---- Manual Page -- http://www.php.net/manual/en/function.set-include-path.php Edit -- https://master.php.net/note/edit/103915 Del: integrated -- https://master.php.net/note/delete/103915/integrated Del: useless -- https://master.php.net/note/delete/103915/useless Del: bad code -- https://master.php.net/note/delete/103915/bad+code Del: spam -- https://master.php.net/note/delete/103915/spam Del: non-english -- https://master.php.net/note/delete/103915/non-english Del: in docs -- https://master.php.net/note/delete/103915/in+docs Del: other reasons-- https://master.php.net/note/delete/103915 Reject -- https://master.php.net/note/reject/103915 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179591) next »