参数传递
方法可以直接接收 GET 参数,并可以赋默认值,空则返回null
// http://www.billge.cc/test/demo4/?id=33 public function action_demo4 ($id =10,$type ,$name ='biny' )- {
// 33 echo ($id );// NULL echo ($type );// 'biny' echo ($name );- }
同时也可以调用param
,get
,post
方法获取参数。
param($key, $default)
获取GET/POST/JSON参数{$key}, 默认值为{$default}
get($key, $default)
获取GET参数{$key}, 默认值为{$default}
post($key, $default)
获取POST参数{$key}, 默认值为{$default}
getJson($key, $default)
如果传递过来的参数为完整json流可使用该方法获取
// http://www.billge.cc/test/demo5/?id=33 public function action_demo5 ()- {
// NULL echo ($this ->param ('name' ));// 'install' echo ($this ->post ('type' ,'install' ));// 33 echo ($this ->get ('id' , 1));- }
注意:
旧版本的getParam
/getPost
/getGet
效果与上面的一致,但已不建议使用