这篇文章主要介绍了php中__autoload和smarty冲突的解决方法,通过spl_autoload_register注册__autoload函数的方法来解决__autoload函数再在smarty无效的问题,需要的朋友可以参考下
一、问题:
最近,在项目中发现,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"); // 添加这段代码
?>
总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。
相关推荐:
thinkphp框架里隐藏index.php
php下载文件的函数实例详解
php使用header方式实现文件下载功能
以上就是php中__autoload和smarty冲突的解决方法详解的详细内容。