PHP autoload oddity?

Not sure why your example isn't working, as it should be as per the manual. Have you tried using spl_autoload_register to register the autoloader function?

Thanks. I got it to work by putting it in the root file of the applicaion, but I'll give spl_autoload_register a try. – Rolf May 1 at 22:47 1 Note: you shouldn't be using __autoload anyways (as only one can be defined).

Use spl_autoload_register instead. See github. Com/symfony/symfony/blob/master/src/Symfony/Component/… – Homer6 May 1 at 22:49 That worked well!

– Rolf May 1 at 23:02.

You're using a relative path to include the class's file. Try an absolute path instead. $dir = __DIR__ .

'/../path/to/mappers'; $file = $dir . '/' . $class_name .

'. Php'; require $file; or // do this outside of __autoload set_include_path(get_include_path() . PATH_SEPARATOR .

__DIR__ . '/../path/to/mappers'; // inside __autoload $file = $class_name .'. Php'; require $file.

I'm using a path relative to the root file. The same path works well for include() and require(). Does __autload() read the path in a different way?

– Rolf May 1 at 22:49 __DIR__ represents the path of the file it is defined in. – Philippe Gerber May 1 at 22:49 1 I guess __autoload will use the path the function is defined in. Not sure though.

– Philippe Gerber May 1 at 22:50 It's not defined in any function. The root file is admin. Php which includes login.php.

Both files are in the same directory, and the path is relative to that directory. – Rolf May 1 at 22:52 I mean the __autoload function. – Philippe Gerber May 1 at 22:54.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions