Smarty模板中调用PHP函数

Smarty模板中调用PHP函数


因为应用需要,要在Smarty中调用PHP函数,实现办法如下:
模板

  1. 数据条数:{$data|count}
  2. 活动页面文件后缀:{$page|substr:'-3'}
  3. 特殊情况:{$page|str_replace:'jpg':'png'}

对应php实现

  1. count($data);
  2. substr($page, -3);
  3. str_replace('jpg''png'$page);

你可能感兴趣的:(Smarty模板中调用PHP函数)