mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-08 08:56:23 +08:00
Merge pull request #67 from FYXing/patch-4
Update structure-controllers.md
This commit is contained in:
@ -361,9 +361,9 @@ class PostController extends Controller
|
|||||||
* `http://hostname/index.php?r=post/view`: 会抛出[[yii\web\BadRequestHttpException]] 异常
|
* `http://hostname/index.php?r=post/view`: 会抛出[[yii\web\BadRequestHttpException]] 异常
|
||||||
因为请求没有提供参数给必须赋值参数`$id`;
|
因为请求没有提供参数给必须赋值参数`$id`;
|
||||||
* `http://hostname/index.php?r=post/view&id[]=123`: 会抛出[[yii\web\BadRequestHttpException]] 异常
|
* `http://hostname/index.php?r=post/view&id[]=123`: 会抛出[[yii\web\BadRequestHttpException]] 异常
|
||||||
因为`$id` 参数收到数字值 `['123']`而不是字符串.
|
因为 `$id` 参数收到数组值 `['123']` 而不是字符串.
|
||||||
|
|
||||||
如果想让动作参数接收数组值,需要指定$id为`array`,如下所示:
|
如果你想要一个动作参数来接受数组值,你应该使用 `array` 来提示它,如下所示:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
public function actionView(array $id, $version = null)
|
public function actionView(array $id, $version = null)
|
||||||
|
|||||||
Reference in New Issue
Block a user