Re: Re: include_path and absolute paths in include functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux