-1 php templates function loading
我在我的项目中创建了2个部分:part1:php engine和part2:html template.
在第1部分我有一个变量:
$test1 = 'This is a var.';
$test2 = 'this is another var.';
Run Code Online (Sandbox Code Playgroud)
在第2部分:我有一个内容:
{echo $test1; echo $test2}
Run Code Online (Sandbox Code Playgroud)
现在,我想创建一个函数,它可以在part2中加载模板并在part1中显示变量的值?
最简单的方法:
foo.php
<?php
$test1 = 'This is a var.';
$test2 = 'this is another var.';
include 'foo.html';
Run Code Online (Sandbox Code Playgroud)
foo.html
...
<?php echo $test1 ?>
<?php echo $test2 ?>
...
Run Code Online (Sandbox Code Playgroud)