我正在开发的网站使用“标题”和“页脚”模板。这些模板包含在网站的每个页面上。标题模板打开HTML并包含完整的标头标签,然后打开标签标签。页脚模板关闭正文标记,然后关闭HTML。的基本结构如下:如何使用php回显php?
<?php
//Set the current page name so it can be highlighted in the menu bar
$page="Home";
//For page-specific HEAD includes
$headincludes=array("<some type of code>","<some other type of code>");
include("/assets/template/header.php");
?>
<!--START PAGE CONTENT-->
<!--END PAGE CONTENT-->
<?php
include("/assets/template/footer.php");
?>
报头模板转储“headincludes”阵列到页面的头部为这样:
foreach ($headincludes as $toecho)
echo $toecho;
此方法工作得很好的东西,如javascript,但是当我尝试添加一条PHP语句时,它会在浏览器的最后一页中以未分析的PHP结尾。有没有一些特殊的方法来用PHP回显PHP?
你能举一个例子,你如何在'$ headincludes'数组中添加php语句? – 2011-03-07 06:34:21
难道你不能只输出没有''标签的php代码吗? – Shoe 2011-03-07 11:36:34