我想包括頭在我的application.I創建了一個控制器site
,並在其中定義的函數header
,這使得數據變量views/header.php
笨包括文件
然而,當我嘗試訪問myUrl/site/header
所有varialble工作正常,但是當我在現場控制器index
中創建另一個功能,並在其中包括views/header
,並且我運行site/index
,那麼我會在標頭中獲得未定義的變量通知。
任何想法?
class site extends CI_Controller { function header() {
$data =array('name'=>'foo');
$this->load->view('includes/header',$data); }
function index() {
$this->load->view('includes/index');
} }
INDEX.PHP
$this->load->view('includes/header');
請張貼您的代碼。 –