如何在thinkPHP5.1框架路由使用get、post請求?針對這個問題,這篇文章詳細(xì)介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
1、在index模塊下的控制器index里面建立一個type方法
public function type(){ var_dump(input()); echo '我是測試類型'; return view(); }
2、在index模塊下新建view視圖建立index文件夾創(chuàng)建type.html頁面
Title
3、設(shè)置路由
//Route::rule('type','Index/index/type','get'); Route::get('type','index/index/type');
//Route::rule('type','index/index/type','post'); Route::post('type','index/index/type'); //或者 //Route::rule('type','index/index/type','get|post');
效果圖:
輸入111
輸出
關(guān)于如何在thinkPHP5.1框架路由使用get、post請求問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識。