Revision: 3716
Updated Code
at September 5, 2007 13:11 by cholmon
Updated Code
function __autoload($classname) { // put the path to your class files here $my_path = "/var/www/mydomain.com/lib"; // tell PHP to scan the default include paht AND your include path set_include_path(get_include_path() . PATH_SEPARATOR . $my_path); // name your classes and filenames with underscores, i.e., Net_Whois stored in Net_Whois.php $classfile = str_replace("_", "/", $classname) . ".php"; include_once($classfile); } /** * EXAMPLE: * create one of your objects, saved in /var/www/mydomain.com/lib/Project/Database.php */ $db = new Project_Database(); /** * EXAMPLE: * create a PEAR object, saved in /usr/local/lib/php/File.php */ $f = new File();
Revision: 3715
Updated Code
at September 5, 2007 13:10 by cholmon
Updated Code
function __autoload($classname) { // put the path to your class files here $my_path = "/var/www/www/mydomain.com/lib"; // tell PHP to scan the default include paht AND your include path set_include_path(get_include_path() . PATH_SEPARATOR . $my_path); // name your classes and filenames with underscores, i.e., Net_Whois stored in Net_Whois.php $classfile = str_replace("_", "/", $classname) . ".php"; include_once($classfile); } /** * EXAMPLE: * create one of your objects, saved in /var/www/www/mydomain.com/lib/Project/Database.php */ $db = new Project_Database(); /** * EXAMPLE: * create a PEAR object, saved in /usr/local/lib/php/File.php */ $f = new File();
Revision: 3714
Updated Code
at September 5, 2007 13:00 by cholmon
Updated Code
function __autoload($classname) { $my_path = "/var/www/www/mydomain.com/lib"; set_include_path(get_include_path() . PATH_SEPARATOR . $my_path); $classfile = str_replace("_", "/", $classname) . ".php"; include_once($classfile); }
Revision: 3713
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 5, 2007 12:47 by cholmon
Initial Code
function __autoload($classname) { $classfile = str_replace('_', '/', $classname) . '.php'; include_once($classfile); }
Initial URL
http://www.drewcking.com
Initial Description
__autoload is often used to load class files from a specific user-defined directory. by simply adding the user-defined directory to the include_path, however, autoload can be used to load user class files as well as PEAR class files. Assuming the PEAR naming convention is adhered to for the user defined classes.
Initial Title
using autoload with PEAR
Initial Tags
Initial Language
PHP