Home >Backend Development >PHP Tutorial >PHP native template engine The simplest template engine
The code is as follows:
$a = array(
'a','b','c'
);
require 'template/demo.php';//Reference template
?>
Template file:
Copy code The code is as follows:
php print_r($a); ?>
Copy code The code is as follows:
Key value: =$value?>
//Iteration of array
//smarty:
{foreach item=na from=$a key=key}
Key value: {$key}
{/foreach}
//Which one is better understood by PHP programmers?
//smarty also uses regular expressions to parse templates. PHP’s regular expressions are not that efficient...