-1

私は私のプロジェクトで 2 つの部分を作成しました: 部分 1: php エンジンと部分 2: html テンプレート。

パート1には変数があります:

$test1 = 'This is a var.';
$test2 = 'this is another var.';

そしてパート2:私はコンテンツを持っています:

{echo $test1; echo $test2}

さて、part2でテンプレートを読み込み、part1で変数の値を表示できる関数を作りたいですか?

4

1 に答える 1

6

最も簡単な方法:

foo.php

<?php

$test1 = 'This is a var.';
$test2 = 'this is another var.';

include 'foo.html';

foo.html

...
<?php echo $test1 ?>
<?php echo $test2 ?>
...
于 2012-08-09T02:03:01.030 に答える