autoload kalsa
Na localhost-u mi radi al kad uplodujem projekat na server ne moze da nadje klase dobijam gresku:
Fatal error: Class 'Core' not found in /home/a4899216/public_html/index.php on line 9
kod je sledeci u iindex stranici
<?php
//load classes
require_once 'inc/autoload.php';
//instatiate Core class
$core = new Core();
$core->run();
?>
autoload.php se nalazi u folderu inc i sadrzi sledeci kod za automtsko lodovanje klasa koje se nalaze u folder classes
<?php
function __autoload($class_name)
{
try
{
$class_file = 'classes/'. strtolower($class_name).'.php';
if(is_file($class_file))
{
require_once $class_file;
}
else
{
throw new Exception("Unable to load class $class_name in file $class_file.");
}
}
catch (Exception $e)
{
$e->getMessage();
}
}
?>
|