Home  >  Article  >  Backend Development  >  PHP的MVC框架中怎么解析模板的,

PHP的MVC框架中怎么解析模板的,

WBOY
WBOYOriginal
2016-06-06 20:38:57996browse

比如$this->assign('a',$dd);
$this->display(xx/xx.html);
在模板中 ,这些是怎么解析的

回复内容:

比如$this->assign('a',$dd);
$this->display(xx/xx.html);
在模板中 ,这些是怎么解析的

最简单的方法就是用正则,这是我写的一个 PHP 模板编译器,可供参考:
https://github.com/jysperm/LightPHP/blob/master/View/CompiledTemplate.php

<code>preg_relpace函数把 替换成 ;?>,然后把中间的字符a匹配到 ,顺便给加个 $ 前缀,再顺便加个 echo 在前面,就成了 <?php echo $a;?>再顺便生成一个新的 xx.php文件,把它包含进来,呵呵。
</code>
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