2016-04-14 109 views
1
<title>Login</title> 

    <!-- CSS --> 
    <?php echo link_tag('assets/css/bootstrap.min.css')?> 
    <?php echo link_tag('assets/font-awesome/css/font-awesome.min.css')?> 
    <?php echo link_tag('assets/css/form-elements.css')?> 
    <?php echo link_tag('assets/ico/favicon.png')?> 
    <?php echo link_tag('assets/ico/apple-touch-icon-144-precomposed.png')?> 
    <?php echo link_tag('assets/ico//apple-touch-icon-114-precomposed.png')?> 
    <?php echo link_tag('assets/ico//apple-touch-icon-72-precomposed.png')?> 
    <?php echo link_tag('assets/ico//apple-touch-icon-57-precomposed.png')?> 
</head> 

我沒寫任何控制器或模型類,只是包括在頁面上面的樣式和圖片,它顯示的消息:「消息:調用未定義函數link_tag()「錯誤,即使我已經在config/autoload文件中寫入以下代碼$ autoload ['helper'] = array('url');」「Error eCodeInteger錯誤消息:消息:調用未定義功能link_tag(

+0

自動加載的網址助手和HTML幫助應用程序>配置> autoload.php – user4419336

回答

2

link_tag()是一個在HTML助手中定義的函數。您應該首先加載HTML助手。

您有2個選項,第一個:

打開,application/config/autoload.php並添加輔助陣列'html'值。

第二個:

添加此行代碼頂部。

$this->load->helper('html'); 

然後,編輯您的線路是這樣的:

$link = array 
      (
      'href' => 'assets/css/bootstrap.min.css', 
      'rel' => 'stylesheet', 
      'type' => 'text/css', 
     ); 

echo link_tag($link); 

但我認爲你可以只使用site_url()功能。如果你想使用site_url(),你應該加載網址助手和編輯您的線條如下圖所示:

<link href="<?php echo site_url('assets/css/bootstrap.min.css'); ?>" rel="stylesheet" type="text/css" /> 
+0

我加$ this-> load-> helper('html');在自動加載.php它將錯誤更改爲消息:未定義的屬性:CI_Loader :: $加載 –

+0

不,這是錯誤的。請仔細閱讀我寫的內容。如果你想自動加載它,你只需要編輯'$ autoload ['helper'] = array();'line to'$ autoload ['helper'] = array('html');'但是正如我所說的,我認爲你只需加載url helper而不是html helper,並使用''link href =「<?php echo site_url('assets/css/bootstrap.min.css');?>」rel =「stylesheet」type =「text/css「/>'結構。 –

0

嘗試使用base_url();代替。

<?php echo base_url('assets/css/bootstrap.min.css')?> 
+0

同樣的錯誤信息:調用未定義功能BASE_URL( ) –

+0

如果你想使用base_url()函數,你應該加載URL助手。也請使用site_url()而不是base_url()。 –

+0

$ this-> load-> helper('url');把它添加到你的控制器中。 –