Home > Backend Development > PHP Tutorial > PHP native template engine The simplest template engine

PHP native template engine The simplest template engine

高洛峰
Release: 2023-03-02 15:20:02
Original
1646 people have browsed it

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:




Template test



 

 



Copy code The code is as follows:
Key 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...

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template