Home > php教程 > php手册 > php autoload:解决 PHP 中的 __autoload 和 Smarty 冲突

php autoload:解决 PHP 中的 __autoload 和 Smarty 冲突

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-21 08:51:10
Original
1385 people have browsed it

        最近,在项目中发现,PHP 的 __autoload 方法失效了。调试了好久,百思不得其解,查了下资料才知道原来是 Smarty 的原因。新版的 Smarty 改变了autoload的方式。
        解决方法是:在 Smarty 的包含类文件后加一段代码,spl_autoload_register("__autoload");
        如下:
define('ROOT_PATH', dirname(__FILE__));
require_once ROOT_PATH . '/includes/smarty/Smarty.class.php';
spl_autoload_register("__autoload"); // 添加这段代码
?>
本文链接http://www.cxybl.com/html/wlbc/Php/20121013/32997.html



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template