I have a server with many customers on, when I develop I include my init.php in which I have an __autoloader()
function that includes the file with dir_name(__FILE__)."/classes/".$className
for instance.
But yesterday I saw that the server could not find the specific class, I restartat apache and then it worked again.
Every customer has this own init.php... ( and therefore many __autoloads on the same server )
customer1/init.php : holds __autoload() customer1/classes/class.php customer2/init.php : holds __autoload() customer2/classes/class.php
I have not done some tests and I hope someone can answer my question before I try to reproduce the problem, but do you think it is possible for php to take the wrong autoload function when you get 2 or more requests at the same time?
Is spl_autoload_register the solution?
Many thanks for some ideas or brainstorming.
My guess is that you should have a typo in either one of your __autoload() functions or you are including the wrong init.php file.
Also, dir_name() does not exist, you should change that to dirname() instead or you can also use the new DIR constant for the same effect if you're using PHP >= 5.3.
EDIT: In light of your comment, use should use:
require(realpath(dirname(__FILE__)) . '/classes/' . $className);
or
require(realpath(__DIR__) . '/classes/' . $className);