首页 > 代码库 > Yii框架请求

Yii框架请求

$request = Yii::$app->request;

$get = $request->get(); 
// 等价于: $get = $_GET;

$id = $request->get(‘id‘);   
// 等价于: $id = isset($_GET[‘id‘]) ? $_GET[‘id‘] : null;

$id = $request->get(‘id‘, 1);   
// 等价于: $id = isset($_GET[‘id‘]) ? $_GET[‘id‘] : 1;

$post = $request->post(); 
// 等价于: $post = $_POST;

$name = $request->post(‘name‘);   
// 等价于: $name = isset($_POST[‘name‘]) ? $_POST[‘name‘] : null;

$name = $request->post(‘name‘, ‘‘);   
// 等价于: $name = isset($_POST[‘name‘]) ? $_POST[‘name‘] : ‘‘;

Yii框架请求