Re: Re: include_path and absolute paths in include functions

From: Date: Fri, 12 May 2006 01:21:55 +0000
Subject: Re: Re: include_path and absolute paths in include functions
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-236047@lists.php.net to get a copy of this message
If you are using PHP 5, you might have some fun with the __autoload() function. I use something like this in production: //---------------------------------------------------------------------- function __autoload($class_name) {
       require_once ($class_name.".php");
} function push_libs() {
       $paths = func_get_args();
       foreach ($paths as $path) {
               $ipath = ini_get("include_path").":".dirname(__FILE__)."/".$path;
               ini_set("include_path", $ipath);
       }
} // where are the class files? push_libs("lib", "lib/application", "lib/db", "lib/ui", "lib/util", "lib/xmlrpc"); //---------------------------------------------------------------------- This code assumes that all the included library paths are relative to the file which contains this code. Dante

« previous php.general (#236047) next »