Home >Backend Development >PHP Problem >What is smarty php method
smarty php method refers to the "Smarty:php" function, and "{php}" is only available in SmartyBC, with syntax such as "{php}include('/path/to/display_weather.php') ;{/php}".
Recommended: "PHP Video Tutorial"
Smarty:php function
{php}
Important Note
Smarty has deprecated the {php} tag and it is strongly recommended not to use it. Please put your PHP logic into a PHP program or plug-in function.
Warm reminder:
In Smarty 3.1, {php} is only available in SmartyBC. The
{php} tag allows PHP code to be directly embedded in the template. Whether these codes are encoded depends on the setting of $php_handling.
Example 7.61. Use of {php} tag
{php} // including a php script directly from the template. include('/path/to/display_weather.php'); {/php}
Example 7.62. Use global variables in {php} tag to assign variables
{* 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 *} <strong>{$varX}</strong> is my fav ice cream :-)
See $php_handling, {include_php}, {include}, {insert} and componentized templates.
The above is the detailed content of What is smarty php method. For more information, please follow other related articles on the PHP Chinese website!