Home  >  Article  >  php教程  >  PHP is the simplest and simplest template engine: PHP native template engine

PHP is the simplest and simplest template engine: PHP native template engine

大家讲道理
大家讲道理Original
2016-11-08 17:27:391508browse

<?php
$a = array(
 &#39;a&#39;,&#39;b&#39;,&#39;c&#39;
);
 
require  &#39;template/demo.php&#39;;//引用模板
?>

Template file:

<!DOCTYPE html>
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title> 模板测试 </title>
</head>
<body>
<?=$a[1]?>
<pre class="brush:php;toolbar:false">
<?php print_r($a); ?>
<pre class="brush:php;toolbar:false">
</body>
</html>
<?php foreach ($a as $value){ ?>
  键值: <?=$value?><br />
<?php } ?>
 
//数组的迭代
 
//smarty:
{foreach item=na from=$a key=key}
键值:{$key} <br>
{/foreach}
 
//对于PHP程序员那个更好理解呢?
//smarty 解析模板还用到正则,PHP的正则效率不会高到哪里去吧...


Statement:
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
Previous article:PHPExcel codeNext article:PHPExcel code