【发布时间】:2012-05-21 21:21:46
【问题描述】:
我想在我的网站中包含一个 header.php 文件。我目前有以下:
header.php
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="<?php if(isset($depth)){echo $depth;};?>css/style.css">
functions.php
function include_layout_template($template="", $depth="")
{
global $depth;
include(SITE_ROOT.DS.'public'.DS.'layouts'.DS.$template);
}
index.php
<?php include_layout_template('header.php', "../"); ?>
但是 $depth 消失了,我什至无法回显 $depth;它只是空白。如何获取在 header.php 中使用的深度变量?
【问题讨论】:
-
$depth 既是全局变量又是函数
include_layout_template的参数?那一定是搞砸了……
标签: php function variables include