smarty 怎么注册类的函数(别的类和本类),并且使用!

ihefe 2010-06-21 11:47:42
rq 谢谢
...全文
136 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ihefe 2010-06-21
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 piger920 的回复:]

引用 6 楼 ihefe 的回复:
引用 5 楼 piger920 的回复:

register_function这个函数貌似在smarty3下已经别的不可用的


有什么好的方法调用函数吗

smarty是分离了HTML和代码,但是怎么使用代码郁闷死

不明白你的意思
你在php这边执行好了 把要显示的assign一下 为啥非要在tpl那边执行呢
[/Quote]

晕了 我用了PHPLIB TEAMPLATE模板的方法 所以出错了 谢谢
ihefe 2010-06-21
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 piger920 的回复:]

引用 6 楼 ihefe 的回复:
引用 5 楼 piger920 的回复:

register_function这个函数貌似在smarty3下已经别的不可用的


有什么好的方法调用函数吗

smarty是分离了HTML和代码,但是怎么使用代码郁闷死

不明白你的意思
你在php这边执行好了 把要显示的assign一下 为啥非要在tpl那边执行呢
[/Quote]

class bll
{
function index()
{
$tpl->template_dir = array("template/index/","template/login/");
$tpl->compile_dir = "libs/templates_c/";
$tpl->config_dir = "libs/configs/";
$tpl->cache_dir = "libs/cache/";
$tpl->left_delimiter = "<{";
$tpl->right_delimiter = "}>";
$tpl->assign('echo',self::user_manager());/////这样吗?
$tpl->parse('reg',"reg.html");//自己加的1个函数,功能是加载页面
$tpl->display(index.tpl); //index.tpl//reg在index里出现
}
function user_manager()
{
//这个地方对数据库的操作
if() return '成功'; else return '失败';
}
}

PIGer920 2010-06-21
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 ihefe 的回复:]
引用 5 楼 piger920 的回复:

register_function这个函数貌似在smarty3下已经别的不可用的


有什么好的方法调用函数吗

smarty是分离了HTML和代码,但是怎么使用代码郁闷死
[/Quote]
不明白你的意思
你在php这边执行好了 把要显示的assign一下 为啥非要在tpl那边执行呢
ihefe 2010-06-21
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 piger920 的回复:]

register_function这个函数貌似在smarty3下已经别的不可用的
[/Quote]

有什么好的方法调用函数吗

smarty是分离了HTML和代码,但是怎么使用代码郁闷死
PIGer920 2010-06-21
  • 打赏
  • 举报
回复
register_function这个函数貌似在smarty3下已经别的不可用的
ihefe 2010-06-21
  • 打赏
  • 举报
回复
额 smarty没人用吗

$tpl->register_function("user_manager", "user_manager");

注册函数 怎么调用别的类的函数 和本类的函数
ihefe 2010-06-21
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 shengxingxingye 的回复:]

$smarty.foreach
[/Quote]

比如我把smarty写在
class bll
{
function index()
{
$tpl->template_dir = array("template/index/","template/login/");
$tpl->compile_dir = "libs/templates_c/";
$tpl->config_dir = "libs/configs/";
$tpl->cache_dir = "libs/cache/";
$tpl->left_delimiter = "<{";
$tpl->right_delimiter = "}>";
$tpl->parse('reg',"reg.html");//自己加的1个函数,功能是加载页面
$tpl->display(index.tpl); //index.tpl//reg在index里出现
}
function user_manager()
{
//这个地方对数据库的操作
if() return '成功'; else return '失败';
}
}

怎么用user_manager函数
shengxingxingye 2010-06-21
  • 打赏
  • 举报
回复
$smarty.foreach
ihefe 2010-06-21
  • 打赏
  • 举报
回复
up~~~

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧