내 사이트 전체에 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', "../"); ?>
그러나 $ 깊이 사라짐 : 저는 현재 다음이 echo $ depth; 그냥 비어 있습니다. header.php에서 사용할 깊이 변수를 어떻게 얻을 수 있습니까? 이 첫 번째 매개 변수로 전달하지만 글로벌 매개 변수를 사용하도록 정의되어 있기 때문에
$ depth는 전역 변수이며'include_layout_template '함수의 매개 변수입니다. 그 일이 엉망이 될거야 ... – Yaniro