Jim
Jim

Reputation: 3

spl_autoload problem

I'm having a problem with this spl_autoload and a static method. The constructor in this class requires two params to function. I'm new to autoload and static classes so I'm out of my league a bit here. Hopefully someone can shed some light on this for me.

Here is the call:

if(captcha::validate($post))...

If I require the class apart from the spl_autoload function, it works as expected. If I let autoload handle it, as it should, the script dies with this message:

Fatal error:  Class 'captcha' not found...

Can someone tell me what I am doing wrong here?

Upvotes: 0

Views: 508

Answers (1)

Sarfraz
Sarfraz

Reputation: 382746

Here is the official manual of spl_autoload

Or try below function:

function my_autoload($className, $extList='.inc,.php') {
  $ext = explode(',',$extList);
  foreach($ext as $x) {
    $fname = $className.$x;
    if(@file_exists($fname)) {
        require_once($fname);
        return true;
    }
  }
  return false;
}

Upvotes: 1

Related Questions