🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
``` <?php namespace app\controllers; use yii\web\Controller; class HelloController extends Controller{ public function actionIndex(){ //YII全局类,前面带\表示命名空间在当前目录 //在这个全局类里面有一个叫$app的静态变量也叫应用主体 //这个应用主体加载了各种各样的组件 //request请求组件 $request=\YII::$app->request; echo $request->get('id'); echo $request->post('name',7444); echo 'method:'.$request->method; echo '<br>'; if($request->isPost){ echo 'this is post method<br>'; }else{ echo 'this is get method <br>'; } echo $request->userIP.'<br>'; echo $request->userHost.'<br>'; echo '<br>'; echo 'hello action'; } } ```