[RESOLVED] __autoload() Debugging

liunx

Guest
Hi,

In my program I'm having a problem. lol. I'm using autoload to load my objects but I'm getting a miscellaneous request for an object that doesn't exist. Of course the error that i get appears to be from the autoload function so i don't know where its coming from.

How can i tell where the autoload function is being called from?

I didn't write this program, its something they gave me to mod at work so I'm not 100% familiar with it.

However, its using the MVC design pattern. Autoload being in the controller, index.php

I don't know what other code to show you...


function __autoload($class)
{

$file = str_replace('_','/',substr($class,2)).'.php5';
require_once(FR_BASE_PATH.'/includes'.$file);

}Well, I found out it was failing because it was trying to include an empty file, so i added a check for file exists in __autoload()

then threw a new exception if it doesn't.

That seems to be working OK for now. but I'm still curious if anybody has other suggestions.I use XDebug for development. If an error occurs, any error at all, it will print out a nice back trace to the screen (among other development niceties it provides).

You could also construct your own similarly by registering an error handler or exception handler and have it print out a back trace. You can use debug_print_backtrace to print out a simple backtrace, or use debug_backtrace to get the individual info in an array and print it out to your liking.cool, thanks
 
Back
Top