smarty php方法指的是“Smarty:php”函数,而“{php}”仅在SmartyBC中可用,语法如“{php}include('/path/to/display_weather.php');{/php}”。

推荐:《PHP视频教程》
Smarty:php函数
{php}
重要说明
立即学习“PHP免费学习笔记(深入)”;
Smarty已经废弃{php}标签,强烈建议不要使用。 请把你的PHP逻辑放到PHP程序或者插件函数中实现。
温馨提示:
SmartB2B 是一款基于PHP、MySQL、Smarty的B2B行业电子商务网站管理系统,系统提供了供求模型、企业模型、产品模型、人才招聘模型、资讯模型等模块,适用于想在行业里取得领先地位的企业快速假设B2B网站,可以运行于Linux与Windows等多重服务器环境,安装方便,使用灵活。 系统使用当前流行的PHP语言开发,以MySQL为数据库,采用B/S架构,MVC模式开发。融入了模型化、模板
在Smarty 3.1,{php}仅在SmartyBC中可用。
{php}标签可以允许PHP代码直接嵌到模板中使用。 这些代码是否被编码,需要取决于$php_handling 的设置.
Example 7.61. {php}标签的使用
{php}
// including a php script directly from the template.
include('/path/to/display_weather.php');
{/php}Example 7.62. {php}标签中使用全局变量来赋值变量
{* this template includes a {php} block that assign's the variable $varX *}
{php}
global $foo, $bar;
if($foo == $bar){
echo 'This will be sent to browser';
}
// assign a variable to Smarty
$this->assign('varX','Toffee');
{/php}
{* output the variable *}
{$varX} is my fav ice cream :-)参见 $php_handling, {include_php}, {include}, {insert} 和 组件化模板.










