php - spl_autoload_register issue -
i don't why error
fatal error: class 'imagejpg' not found
here code use
spl_autoload_register(function($class) { if(file_exists($class)) { include $class.'.php'; } }); $n = new imagejpg();
file imagejpg.php in same dir code above.
here content of imagejpg.php
<?php class imagejpg { public function __construct() { echo 'image jpg called'; } }
is there class named imagejpg in imagejpg.php file? , file exist? try this:
spl_autoload_register(function($class) { if(file_exists($class.'.php')) { include $class.'.php'; if (!class_exists($class)) { die('required class not present'); } } else { die('file not found'); } });
Comments
Post a Comment