1. 程式人生 > >ThinkPhp5獲取請求引數

ThinkPhp5獲取請求引數

獲取請求引數前,需要呼叫Request類

use think\Request

獲取單個請求引數(通用):
$id = Request::instance() -> param( ‘id’ )

獲取所有請求引數(通用):
$all = Request::instance() -> param()

獲取url路徑中的請求引數(路徑):
$id = Request::instance() -> route()

獲取GET請求的引數(GET):
$id = Request::instance() -> get(‘id’)

獲取POST請求的引數(POST):


$id = Request::instance() -> post( ‘id’ )

如何在路由裡帶路徑引數:

  • 只能在確認了請求方式的快捷路由裡帶路徑引數
  • 帶路徑引數的方法為在自定義的路徑名稱後加 “/:請求引數”