// 定义一个函数用来包含模板,并传递数据,应该定义在公用函数库里的,这里我就直接写在这儿了 function template($template,$data) { if(isset($data)){ foreach($data as $key=>$val){ $$key = $val; } unset($data); } include($template); }
template('show.php',$data);
此例当然不是完整的写法,仅仅是一个小小的示例,模板赋值的原理就是这样的。
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