This article describes the usage of smarty template condition judgment in PHP. Share it for your reference. The specific implementation method is as follows:
Template file code:
<html> <head> <title>Smarty Test</title> </head> <body> <table width="200" border="0"> {if $cond == 1} <tr> <td>Conditions are established</td> </tr> {else} <tr> <td>Conditions are not valid</td> </tr> {/if} </table> </body> </html>
php code:
<?php require 'libs/'; //Includes Smarty class library files$smarty = new Smarty; //Create a new Smarty object$cond = 1; $smarty->assign("cond",$cond); // Assign values to variables in the template$smarty->display(''); //Show page?>
I hope this article will be helpful to everyone's PHP programming.