開始做實驗,發現都不行,查了很久,原來 $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預設的一些參數,類似於系統變數。可以到設定檔修改,可以參考樓上的