Pomoc - _autoload() is deprecated

0

Witam, na mojej stronie pojawia się taki problem:

Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in /www/open/app/class/core/cqAutoload.php on line 3

Warning: Cannot modify header information - headers already sent by (output started at /www/open/app/class/core/cqAutoload.php:3) in /www/open/app/class/core/cqRouter.php on line 29

Warning: Cannot modify header information - headers already sent by (output started at /www/open/app/class/core/cqAutoload.php:3) in /www/open/app/class/core/cqRouter.php on line 30

Warning: Cannot modify header information - headers already sent by (output started at /www/open/app/class/core/cqAutoload.php:3) in /www/open/app/class/core/cqRouter.php on line 31

Próbowałem naprawić problem z funkcją autoload korzystając z poradników, niestety nie udało mi się jak do tej pory.
Poniżej zamieszczam cały kod z pliku cqAutoload.php


	function __autoload($class_name)
	{
		$sources[] = __DIR__.'/'.$class_name . '.php';
		$sources[] = __DIR__.'/../helpers/'.$class_name . '.php';
        $sources[] = __DIR__.'/../expono/'.$class_name . '.php';
		$sources[] = __DIR__.'/../ktv/'.$class_name . '.php';

		foreach((array)$sources as $source)
		{
			if(file_exists($source))
			{
				require $source;
				break;
			}
		}

	}

oraz z pliku cqRouter.php


class cqRouter extends AltoRouter {

	function execute($match)
	{
		if($match)
		{
			if($match['params']) cqController::setParams($match['params']);
			$target = explode("#",$match['target']);

			if(isset($target[2]) && $target[2] == "Header")
			{
				define("HEADER","true");
			}
			if(isset($target[2]) && $target[2] == "Cache" && defined("_CACHE_DIR"))
			{
                define("CACHE",md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']));

                if(file_exists(_CACHE_DIR.CACHE) && filemtime(_CACHE_DIR.CACHE) > (time() - _CACHE_LONG) )
                {
                    echo file_get_contents(_CACHE_DIR.CACHE);
                    die;
                }
				header("Cache-Control: max-age="._CACHE_LONG);
			}
			else
			{
				header("Cache-Control: no-cache, must-revalidate"); //HTTP 1.1
				header("Pragma: no-cache"); //HTTP 1.0
				header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
			}

			if(defined("CACHE")) ob_start();
			cqController::__load($target[0],$target[1],$match['params']);
            if(defined("CACHE")) file_put_contents(_CACHE_DIR.CACHE,ob_get_contents());
		}
		else
        {
//			returnError404();
            header("Location: https://open.frp.pl", true, 301);
            exit();
		}
	}
}

Z góry dziękuję za każdą pomoc i uwagę.

0

Wiadomość o błędzie mówi Ci, co powinieneś zrobić - użyć funkcji spl_autoload_register.

W dużym skrócie:

// zamiast robić tak
function __autoload($class_name) { 
    // twój kod...
}

// robisz tak
function jakas_tam_nazwa($class_name) {
    // twój kod
}
spl_autoload_register(jakas_tam_nazwa);

1 użytkowników online, w tym zalogowanych: 0, gości: 1