yii2 使用

核心验证器,字符串限制

[['phone'], 'string', 'length' => [11, 11], 'tooShort' => '请输入11位手机号码', 'tooLong' => '请输入11位手机号码'],

响应json数据

  • web.php中配置components

    'response' => [
      'formatters' => [
          \yii\web\Response::FORMAT_JSON => [
              'class' => \yii\web\JsonResponseFormatter::class,
              'prettyPrint' => YII_DEBUG,
              'encodeOptions' => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE,
          ],
      ],
    ],

此处评论已关闭