smarty3--registerPlugin()函数报错问题
smarty版本:smarty3.1.30
registerPlugin错误信息:
Notice: Trying to get property of non-object in E:\Joomla\system\libs\sysplugins\smarty_internal_templatebase.php on line 245
Fatal error: Call to a member function registerPlugin() on null in E:\Joomla\system\libs\sysplugins\smarty_internal_templatebase.php on line 245
代码示例:
system.smarty.inc.php //smarty模板配置类文件
<?php
require("libs/Smarty.class.php"); //引入smarty类库
class SmartyProject extends Smarty{
function __construct(){ //配置信息
$this->template_dir="./system/templates/";
$this->compile_dir="./system/templates_c/";
$this->config_dir="./system/configs/";
$this->cache_dir="./system/catch/";
}
}
?>
system.inc.php //类的实例化文件
<?php
require("system.smarty.inc.php");
require("system.class.inc.php");
$usefun=new UseFun();
$smarty=new SmartyProject;
function unhtml($params){
extract($params);
$text=$content;
global $usefun;
return $usefun->UnHtml($text);
}
$smarty->registerPlugin('function','unhtml','unhtml'); //注册模板函数
?>
此时会提示错误信息:
Notice: Trying to get property of non-object in E:\Joomla\system\libs\sysplugins\smarty_internal_templatebase.php on line 245
Fatal error: Call to a member function registerPlugin() on null in E:\Joomla\system\libs\sysplugins\smarty_internal_templatebase.php on line 245
解决办法:在smarty配置类文件中,引入父类的构造方法。即将system.smarty.inc.php文件改为:
require("libs/Smarty.class.php");
class SmartyProject extends Smarty{
function __construct(){
parent::__construct(); //引入父类的构造方法
$this->template_dir="./system/templates/";
$this->compile_dir="./system/templates_c/";
$this->config_dir="./system/configs/";
$this->cache_dir="./system/catch/";
}
}
此时函数注册成功!
smarty3--registerPlugin()函数报错问题的更多相关文章
- js执行函数报错Cannot set property 'value' of null怎么解决?
js执行函数报错Cannot set property 'value' of null 的解决方案: 原因:dom还没有完全加载 第一步:所以js建议放在body下面执行, 第二步:window.on ...
- python 3 直接使用reload函数报错
reload()是python2 的内置函数可以直接使用,但是python3 直接使用此函数报错,需要导入importlib 模块 from importlib import reload
- Linux 下使用C语言 gets()函数报错
在Linux下,使用 gets(cmd) 函数报错:warning: the 'gets' function is dangerous and should not be used. 解决办法:采用 ...
- C++ socket bind()函数报错 不存在从 "std::_Binder<std::_Unforced, SOCKET &, sockaddr *&, size_t &>" 到 "int" 的适当转换函数
昨天还可以正常运行的程序,怎么今天改了程序的结构就报错了呢?我明明没有改动函数内部啊!!! 内心无数只“草泥马”在奔腾,这可咋办呢?于是乎,小寅开始求助于亲爱的度娘...... 由于小寅知识水平有限, ...
- 光流法draw_flow()函数报错
光流法draw_flow()函数报错 import cv2 from scipy import * def draw_flow(im, flow, step=16): ""&quo ...
- updatexml和extractvalue函数报错注入
updatexml()函数报错注入 updatexml (XML_document, XPath_string, new_value); 第一个参数:XML_document是String格式,为XM ...
- php 升级到 5.3+ 后出现的一些错误,如 ereg(); ereg_replace(); 函数报错
在php5.3环境下运行,常常会出现 Deprecated: Function ereg() is deprecated in...和Deprecated: Function ereg_replace ...
- PHP empty函数报错的解决办法
PHP empty函数在检测一个非变量情况下报错的解决办法. PHP开发时,当你使用empty检查一个函数返回的结果时会报错:Fatal error: Can't use function retur ...
- Linux下编译C代码,出现tan函数报错的情况
undefined reference to `tan' 但是已经包含了头文件 <math.h>了,可还是报错,说是找不到tan 这个问题的原因不是很清楚, 但是网上给出的方案,就是编译的 ...
- geopandas overlay 函数报错问题解决方案
前言 这篇文章依旧是基于上一篇文章(使用Python实现子区域数据分类统计)而写,此文章中介绍了使用 geopandas 的 overlay 函数对两个 GeoDataFrame 对象取相交或相异的部 ...
随机推荐
- Android ScrollView+ViewPager+PullToRefreshListView
想达到此界面的风格 然后ViewPage里面第一个Fragment是一个瀑布流 这个瀑布流要有加载跟多 在ScrollView中,嵌套ViewPager,在ViewPager的每页使用Fragment ...
- C# 模拟POST提交文件
http://blog.csdn.net/hellowjwang/article/details/19975635 public class HttpPost { /// <summary> ...
- sudo: ./sd_fusing.sh:找不到命令
1. -----
- bzoj4008
好题,这题可以分开算每个技能的贡献 orz popoqqq http://blog.csdn.net/popoqqq/article/details/45365759 ..,..] of double ...
- bzoj1854
神奇了 朴素的做法不难想,二分图最大匹配(汗,我其实还是想了一会,太弱了) 左边点集为能打的属性值,右边把武器作为一个点 武器和两个属性连边, 然后和superhero那题差不多,顺次找匹配,找不到了 ...
- ShareSDK 实现新浪微博分享(微信,QQ,新浪微博类似)
1 . 分享(前提是集成了sdk,配置好了Key),只要实现点击事件,调用shareSina(); ShareSDK.initSDK(this); private void shareSina() { ...
- I.MX6 Android USB Touch eGTouchA.ini文件存放
/******************************************************************** * I.MX6 Android USB Touch eGTo ...
- 常用ping服务列表
以下是收集的ping服务器. ping是基于XML_RPC标准协议的更新通告服务,是用于blog在内容更新时通知博客搜索引擎及时进行抓取.更新的方式.博客搜索引擎在成功接受到ping以后,会立刻进行抓 ...
- HDU 5698 瞬间移动
瞬间移动 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submis ...
- dephi WaitForMultipleObjects 用法
在Delphi中WaitForMultipleObjects的使用 procedure ThreadTest;stdcall; var Handles:TWOHandleArray; //Hand ...