yii接值方式判断以及获取当前用户ip

来源:互联网 发布:电脑位数怎么看 mac 编辑:程序博客网 时间:2024/06/08 19:54
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}
0 0