2013-03-10 58 views
1

我想呼應BASE_URL()像這樣使用BASE_URL():不能在笨

editor_header.php

<link href="<?php echo base_url(); ?>/css/bootstrap.css" rel="stylesheet" media="screen"> 

爲editor_header.php控制器看起來像這樣:

<?php 
class Pages extends CI_Controller { 

    public function view($page = 'home') 
    { 

     if (! file_exists('application/views/pages/'.$page.'.php')) 
     { 
      // Whoops, we don't have a page for that! 
      show_404(); 
     } 

     $data['title'] = ucfirst($page); // Capitalize the first letter 
      $this->load->view('head&foot/editor_header', $data); 
    } 
} 
?> 

我已經啓用url_helper在autoload.php像這樣

$autoload['helper'] = array('url'); 

但我仍然得到錯誤:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /Applications/XAMPP/xamppfiles/htdocs/editor/application/controllers/pages.php on line 5 

pages.php高於控制器。

我的問題

請任何人都可以提出建議,爲什麼editor_header.php不能使用BASE_URL?提前致謝。

+0

什麼是整個錯誤消息? – Repox 2013-03-10 17:00:54

+0

我已更新我的回答 – 2013-03-10 17:03:35

+0

您運行的是哪個版本的PHP? – Repox 2013-03-10 17:05:18

回答

1

更改控制器這樣的代碼,看看它是否工作

class Pages extends CI_Controller { 

    public function view($page = 'home') 
    { 
     $path = APPPATH . 'views/pages' . $page . '.php'; 
     if (! file_exists($path)) 
     { 
      show_404(); 
     } 

     $data['title'] = ucfirst($page); 
     $this->load->view('head&foot/editor_header', $data); 
    } 
}