2017-09-11 145 views
0

我使用此代碼,但對於它,我必須逐步寫入所有鏈接到我的配置文件。有沒有其他更好的方法來做到這一點。是否有任何其他方式允許破折號在Codeigniter

在此先感謝。

那怎麼我的代碼看起來像

控制器:

<?php 

/** 
* 
*/ 
class Drink_cola extends CI_Controller 
{ 

    function __construct() 
    { 
     parent::__construct(); 
    } 

    function index() 
    { 
     $this->load->view("header.php"); 
     $this->load->view("abc.php"); 
     $this->load->view("footer.php"); 
    } 

} 

?> 

一件事我在routes.php文件做允許破折號是這樣的:

routes.php文件

$route['translate_uri_dashes'] = TRUE; 
$route['Drink-cola'] ='Drink_cola'; 
+0

問題到底是什麼? – tilz0R

+0

@ tilz0R我要求其他選項。 – Atif

+0

如果我複製你的課程到我的項目文件夾 - 它的作品像一個魅力 – sintakonte

回答

0

其實有。寫在你的/application/config/routes.php如下:

$route['translate_uri_dashes'] = true; 

這個確切的主題記錄here

+0

我已經做了這個,但它不是在多個url參數上工作,例如:ex.com/drink-cola – Atif

+0

CI的哪個版本是你使用的? – sintakonte

+0

3.1.5。當前版本 – Atif

0

打開文件/application/config/routes.php並添加路由數組中的以下行:

$route['translate_uri_dashes'] = TRUE; 

它將你的MY_CONTROLLER自動翻譯成我的控制器或小字母。

+0

我已經這樣做了,但它不能處理多個url參數,例如:ex.com/drink-cola – Atif

+0

您需要傳遞如下值:$ route ['com/drink-cola'] ='Maincontroller' ; $ route ['translate_uri_dashes'] = TRUE; 我可以向你保證它會工作 – nairsumesh1991

+0

我知道,但沒有其他選擇嗎? – Atif

相關問題