Thinkphp 中 path info 方法傳入的變數 不能單個字元,為什麼呢?

來源:互聯網
上載者:User
關鍵字 thinkphp php
開始做實驗,發現都不行,查了很久,原來 $a,$b 都是一個字母的,改成 $aa,$bb 行了:

//訪問:http://localhost/yb1/index.php/Home/Abcde/test/a/1/b/2//錯誤!class AbcdeController extends Controller {    public function test($a,$b)    {        echo "本次傳入的a值是".$a.",b值是".$b;    }}
//訪問:http://localhost/yb1/index.php/Home/Abcde/test/aa/1/bb/2//正確!class AbcdeController extends Controller {    public function test($aa,$bb)    {        echo "本次傳入的a值是".$aa.",b值是".$bb;    }}

請問這是什麼原因?是PHP的規定?,還是thinkPHP的規定?

看什麼資料才能知道那些我不知道的坑?

回複內容:

開始做實驗,發現都不行,查了很久,原來 $a,$b 都是一個字母的,改成 $aa,$bb 行了:

//訪問:http://localhost/yb1/index.php/Home/Abcde/test/a/1/b/2//錯誤!class AbcdeController extends Controller {    public function test($a,$b)    {        echo "本次傳入的a值是".$a.",b值是".$b;    }}
//訪問:http://localhost/yb1/index.php/Home/Abcde/test/aa/1/bb/2//正確!class AbcdeController extends Controller {    public function test($aa,$bb)    {        echo "本次傳入的a值是".$aa.",b值是".$bb;    }}

請問這是什麼原因?是PHP的規定?,還是thinkPHP的規定?

看什麼資料才能知道那些我不知道的坑?

thinkphp3預設設定了很多單字母變數用於支撐他的URL普通模式訪問,比如
segmentfault.com/?m=index&c=goods&a=detail&id=1818

在下面圖片中的路徑和檔案中可以看到,當然這些變數名是可以修改的

a b是TP url預設的一些參數,類似於系統變數。可以到設定檔修改,可以參考樓上的

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.