smarty3.0和__autoload()冲突
来源:互联网 发布:重启mysql命令 编辑:程序博客网 时间:2024/05/22 06:23
今天更新了一下smarty到3.0,结果发现项目中的__autoload()不能用了,原来是因为smarty改变了autoload的方式。
解决方法如下:
function autoload($className){
if (file_exists(SITEROOT.'include/module/'.$className.'.class.php'))
include SITEROOT.'include/module/'.$className.'.class.php';
else
die('类'.$className.'文件不存在');
}
spl_autoload_register("autoload");
用上面的方式还可以依顺序同时载入几个autoload方法哦
来源: http://hi.baidu.com/aboc/blog/item/b9130ff4345ce978ddc474c3.html
另有解决办法如下
bimal at sanjaal dot com05-Jun-2011 06:58
When multiple scripts try to use __autoload(), there is a collision.
I experienced it while upgrading the Smarty and my own autoload function.
So, the better way is to avoid __autoload() and use spl_register_autoload() instead. If you have written this already, just rename your function to something like __autoload_my_classes, and in the next, call spl_autoload_register as:
<?php
function __autoload_my_classes($classname)
{
# ... your logic to include classes here
}
spl_autoload_register('__autoload_my_classes');
?>
You can assign multiple functions to spl_autoload_register() by calling it repeatedly with different function names. Be sure to limit your every function to include a CLASS file.
from: http://cn2.php.net/manual/en/language.oop5.autoload.php#104282
- smarty3.0和__autoload()冲突
- smarty3.x和__autoload冲突解决方案
- Smarty3.0跟php的__autoload()有冲突
- 解决 PHP 中的 __autoload 和 Smarty 冲突
- php模版引擎(smarty3)—优化(定界符,避免和其他语言的冲突)
- __autoload()和spl_autoload_register()
- __autoload和spl_autoload_register()
- Smarty3.0 使用指南
- smarty3
- __autoload
- Smarty3和Smarty2的区别
- PHP函数__autoload()和spl_autoload_register()
- PHP函数: __autoload()和spl_autoload_reigster()
- 117 php __autoload 和 spl_autoload_register
- __autoload()和spl_autoload_register()的理解
- [转]Smarty3.0 新特征
- Smarty3.0 最新使用指南使用手册
- 1.smarty3的安装和使用
- Linux进程通信-信号量
- Linux进程通信-共享内存
- 数组与广义表_稀疏矩阵的压缩存储_三元组做存储结构_矩阵相乘
- Linux进程通信-内存映射
- Objective-C语法之词典对象的那些事儿(八)
- smarty3.0和__autoload()冲突
- Linux进程通信-消息队列
- oracle体系结构学习笔记
- Android核心模块内容概述
- Linux信号透彻分析与理解
- Linux进程通信-信号
- Objective-C语法之数组对象的那些事儿(七)
- Socket.IO 简介
- Android应用程序开发入门