我用一個函數構建css鏈接,但如果我沒有在最後做一個var_dump,那麼css將無法工作。我錯過了什麼或沒有看到?當我不做var_dump時,php不加載腳本
代碼:
private function buildCssLinks(){
$files = $this->findFiles(dirname(dirname(__FILE__))."/css","css");
foreach ($files as $id)
{
$pathInfo = pathinfo($id);
$fileName = $pathInfo['basename'];
$files[] = '<link rel="stylesheet" type="text/css" href="css/' . $fileName . '">';
}
return implode("",$files);
}
回報
,但是當我在我的代碼
private function buildCssLinks(){
$files = $this->findFiles(dirname(dirname(__FILE__))."/css","css");
foreach ($files as $id)
{
$pathInfo = pathinfo($id);
$fileName = $pathInfo['basename'];
$files[] = '<link rel="stylesheet" type="text/css" href="css/' . $fileName . '">';
}
var_dump($files);
return implode("",$files);
}
添加一個變種轉儲第二回
調用__construct
public function __construct($header, $body, $footer)
{
$this->header = $header;
$this->body = $body;
$this->footer = $footer;
$this->buildHeader();
$this->buildBody();
$this->buildFooter();
$js = $this->buildJsLinks();
$css = $this->buildCssLinks();
$this->header = $css;
$this->footer = $js;
}
我得到你需要的呼應buildCssLinks的感覺()。 –
你能告訴我們調用buildCssLinks的代碼嗎? – WEBjuju
@WEBjuju我加了電話代碼 – HomeForce