I have a autoload function like this:
function __autoload($class)
{
//define('DOCROOT', dirname(__FILE__));
$filename = "../sys/class/class." . strtolower($class) . ".inc.php";
//$filename = DOCROOT . "/sys/class/class." . strtolower($class) . ".inc.php";
if ( file_exists($filename) )
{
include_once $filename;
}
}
I renamed the smarty file to class.smarty.inc.php
so it's included in the autoload, but I get this error:
Fatal error: Class 'Smarty_Internal_Template' not found in /var/www/v3/sys/class/class.smarty.inc.php on line 441
Don't know what that mean..
Do NOT modify 3rd-party-libraries. Just create a second autoloader that follows Smarty's naming convention.
function defaultAutoloader($className) {
// your code ($file = /path/to/my/lib/{{ CLASS }}.inc.php)
if (file_exists($file)) {
require $file;
return true;
}
return false;
}
function smartyAutoloader($className) {
// code ($file = /path/to/smarty/{{ CLASS }}.php)
if (file_exists($file)) {
require $file;
return true;
}
return false;
}
spl_autoload_register('defaultAutoloader');
spl_autoload_register('smartyAutoloader');
The way your autoloader maps the classname to a filename leads to the filename class.smarty_internal_template.inc.php
, which is obviously not the filename you expect. I dont know how Smarty is structured, but you should make sure the autoloader can find any of its classes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.