jeboy Posted July 1, 2008 Share Posted July 1, 2008 Is it possible to use two __autoload function in a script? For example one autoload function that will load classes from one folder and another autoload for another folder. Link to comment https://forums.phpfreaks.com/topic/112737-is-it-possible-to-use-two-__autoload-function-in-a-script/ Share on other sites More sharing options...
trq Posted July 1, 2008 Share Posted July 1, 2008 No, you will get an error about 'cannot redeclare __autoload function'. What you can do however is make __autoload look in two locations. eg; function __autoload($class) { if (file_exists("local/includes/$class.php")) { require_once "local/includes/$class.php"; } elseif (file_exists("../sitewide/includes/$class.php")) { require_once "../sitewide/includes/$class.php"; } } Failing that, take a look at the standard php library's autoload implimentaion. Link to comment https://forums.phpfreaks.com/topic/112737-is-it-possible-to-use-two-__autoload-function-in-a-script/#findComment-579027 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.