1 year ago

#387328

test-img

Sushant Sharma

Error on xampp running phph code Fatal error spl_autoload_register()

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.");
    }

ERROR : Fatal error: __autoload() is no longer supported, use spl_autoload_register() instead in C:\xampp\htdocs\jobportal\include\function.php on line 37

This is the code of a job portal please help I don't understand how to resolve I am new in development new learner if you can help please please.

I am running this on xampp

function 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.");
    }
                
});

ERROR Parse error: syntax error, unexpected token "function", expecting variable in C:\xampp\htdocs\jobportal\include\function.php on line 37

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.");
    }
                
});

and when I am not using function keyword then

ERROR Fatal error: Uncaught Error: Call to undefined function get_magic_quotes_gpc() in C:\xampp\htdocs\jobportal\include\database.php:15 Stack trace: #0 C:\xampp\htdocs\jobportal\include\database.php(132): Database->__construct() #1 C:\xampp\htdocs\jobportal\include\accounts.php(2): require_once('C:\xampp\htdocs...') #2 C:\xampp\htdocs\jobportal\include\initialize.php(17): require_once('C:\xampp\htdocs...') #3 C:\xampp\htdocs\jobportal\index.php(2): require_once('C:\xampp\htdocs...') #4 {main} thrown in C:\xampp\htdocs\jobportal\include\database.php on line 15

php

codeigniter

xampp

0 Answers

Your Answer

Accepted video resources