Home > php教程 > PHP源码 > body text

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

大家讲道理
Release: 2016-11-08 17:27:39
Original
1551 people have browsed it

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

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>
Copy after login
<?php foreach ($a as $value){ ?>
  键值: <?=$value?><br />
<?php } ?>
 
//数组的迭代
 
//smarty:
{foreach item=na from=$a key=key}
键值:{$key} <br>
{/foreach}
 
//对于PHP程序员那个更好理解呢?
//smarty 解析模板还用到正则,PHP的正则效率不会高到哪里去吧...
Copy after login


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template