1. 程式人生 > >yii接值方式判斷以及獲取當前使用者ip

yii接值方式判斷以及獲取當前使用者ip

public function actionDemo(){
$req=\YII::$app->request;
echo $req->get('id');//以get方式接值
echo $req->post("name",3333); //以post方式接值
if($req->isPost){//判斷接值方式為post返回true
echo 'this is post method';
    }
if($req->isGet){//判斷接值方式為get返回true
echo 'this is get method';
    }
echo $req->userIp;//輸出當前IP
}