国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

PHP Smarty中include file問題求救!
帥帥的阿豬
帥帥的阿豬 2017-10-25 20:18:35
0
1
1603

捕獲.JPG

圖片是我的網(wǎng)站目錄,index.php在根目錄下,head.php和實(shí)例化smarty類別檔案(config.php)在include目錄下,templates是存放index .html和head.html檔案的目錄。

想問為什麼我分別在index.php和head.php裡面實(shí)例化了類別,然後assign了一個(gè)屬性,display了對(duì)應(yīng)的html文件,然後在index.html裡面使用{include file= 'head.html'}顯示不存在我在head.php裡面給的變數(shù)?分別存取index.php與head.php正常

貼文程式碼:

index.php檔

<?php
require_once 'include/config.php';
$sm->assign('title','hello');
$sm->display('templates/index.html');
?>

index.html檔

{include file='head.html'}
{$title}
</body>
</html>

head.php檔案

<?php
require_once 'config.php';
$sm->assign('hea','這是head頭部');
$sm->display(FILES.'templates/head.html');
?>

head.html檔

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
{$hea}


帥帥的阿豬
帥帥的阿豬

我是一只帥帥的阿豬

全部回覆(1)
路過

你看看head.php裡面引入檔案的路徑對(duì)嗎?

  • 回覆 是對(duì)的,我單獨(dú)訪問head.php和Index.php都是正常的。
    帥帥的阿豬 作者 2017-10-26 09:36:11
  • 回覆 回覆 0:怎麼算正常? 你用的$sm 實(shí)例化了嗎? 就是 $sm = new Smarty();
    路過 作者 2017-10-26 09:42:39
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板