簡體   English   中英

Codeigniter網址/ controller / function / 1/3

[英]Codeigniter url /controller/function/1/3

我想在函數中傳遞“ 1/3”除法符,但代碼點火器將其視為新的自變量。

例如,我想收到“ 1/3”和“ 50”

我在想/ controller / function / division / number,但是除法被認為是2個參數,有一個函數可以將其轉義? 我嘗試了url_encode,但效果不佳。

在這樣的函數上發送輸入,首先創建為像這樣的字符串“ 1-/-3”或其他任何形式

    Controller side code like this :
    public function yourfuncname($var){

    $inputrec = str_replace("","-",$var);   //this step gives you 1/3

     //other code as per your requirment.
    };

在瀏覽器端,還可以借助javascript或jquery在url鏈接中添加一些已識別的字符。 創建輸入格式為“ 1-/-3”。然后,您就可以在codeignter中的單個參數中發送這些值,以進行進一步處理

根據您要實現的目標,您可能希望將低級分數⅓作為html URL編碼的實體⅓

試試這個: url_title('1 /3');
有關更多詳細信息,請參見http://ellislab.com/codeigniter%20/user-guide/helpers/url_helper.html

或者替代解決方案可以是:

**encode** the value before passing
$value = str_replace(’=’, ‘-’, str_replace(’/’, ‘_’, base64_encode($value)));

**decode** the value after receiving
$value = base64_decode(str_replace(’-’, ‘=’, str_replace(‘_’, ‘/’, $value)));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM