知识屋:更实用的电脑技术知识网站
所在位置:首页 > 编程技术  > PHP编程

解决 PHP 中的 __autoload 和 Smarty 冲突

发表时间:2014-09-05来源:网络

最近,在项目中发现,PHP 的 __autoload 方法失效了。调试了好久,百思不得其解,查了下资料才知道原来是 Smarty 的原因。新版的 Smarty 改变了autoload的方式。


        解决方法是:在 Smarty 的包含类文件后加一段代码,spl_autoload_register("__autoload");

        如下:

<?php  
    define('ROOT_PATH', dirname(__FILE__)); 
    require_once ROOT_PATH . '/includes/smarty/Smarty.class.php'; 
    spl_autoload_register("__autoload");  // 添加这段代码  
?> 

 

摘自 Lee.的专栏
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜