How to __autoload classes, interfaces, functions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ctrLogicDotNet
Forum Newbie
Posts: 24
Joined: Fri Jul 24, 2009 10:52 am

How to __autoload classes, interfaces, functions

Post by ctrLogicDotNet »

Here is the thing,

I read about the __autoload magic function and wanted to know if in this function there would be a way to know if what it tries to __autoload is a class, an interface, a function (even though I think it's not called upon an unfound function)...

Each of these in my implementation are found in different paths, so to require them I would need to have access to this information...

Thank You
solid
Forum Commoner
Posts: 28
Joined: Wed Aug 12, 2009 11:56 am

Re: How to __autoload classes, interfaces, functions

Post by solid »

It doesn't matter, simply check both paths in the __autoload function:

Code: Select all

 
if (file_exists($file_path_a))
{
     require_once($file_path_a);
}
elseif (file_exists($file_path_b))
{
     require_once($file_path_b);
}
 
Post Reply