0

I am trying to run some of my code by each time, I am getting this error, I am using the latest version of PHP.

I replaced my caused as per the error; from this

function __autoload($class_name) {
        $class_name = strtolower($class_name);
        $path = LIB_PATH.DS."{$class_name}.php";
        if(file_exists($path)){
            require_once($path);
        }else{
            die("The file {$class_name}.php could not be found.");
        }

to this

function spl_autoload_register($class_name) {
        $class_name = strtolower($class_name);
        $path = LIB_PATH.DS."{$class_name}.php";
        if(file_exists($path)){
            require_once($path);
        }else{
            die("The file {$class_name}.php could not be found.");
        }

then got another error message

Fatal error: Cannot redeclare spl_autoload_register() in D:\XAMPP\htdocs\marimar\includes\functions.php on line 37

Any help on how to solve this. here is the complete code.

1 Answer 1

0

try this.it worked for me

spl_autoload_register( function( $class_name )
{ 
    $class_name = strtolower( $class_name );
    $path = LIB_PATH.DS."{$class_name}.php"; 
    if( file_exists( $path ) ) 
        require_once($path); 
    else
        die( "The file {$class_name}.php could not be found." );
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.