`
sxysxy
  • 浏览: 214248 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

smarty中的register_modifie函数

 
阅读更多
我的字符串用addslashes解释后,用
$smarty->register_modifier("sslash","stripslashes");
{$blog_id.blog_myblog|truncate:1000|sslash}
进行还原解释。
smarty中的register_modifie函数
2008-02-16 11:46

注册修饰器

void register_modifier (string name, mixed impl)

Use this to dynamically register modifier plugin. Pass in the template modifier name, followed by the PHP function that it implements it.

动态注册一个修饰器插件,需要制定模板修饰器的名称,和实现具体功能的函数。

The php-function callback impl can be either (a) a string containing the function name or (b) an array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string containing the mehod-name or (c) an array of the form array(&$class, $method) with $class being a classname and $method being a class method of that class.

执行函数的格式可以是一个包含函数名称的字符串;也可以是一个array(&$object, $method)数组形式,其中&$object是一个对象的引用,而$method是它的一个方法;还可以是一个array(&$ class, $method)数组形式,其中$class是一个类的名称,$method是类中的一个方法。

Example 13-23. register_modifier
例子 13-23. 注册修饰器

// let's map PHP's stripslashes function to a Smarty modifier.
// 把PHP的stripslashes函数影像为Smarty模板的修饰器


$smarty->register_modifier("sslash","stripslashes");


// now you can use {$var|sslash} to strip slashes from variables
// 现在可以在模板中使用{$var|sslash}的格式来去除变量中的特殊符号了
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics