<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 注解驗證器 ThinkPHP支持使用注解方式定義路由和驗證,需要安裝額外的擴展: ``` composer require topthink/think-annotation ``` 然后可以直接在控制器類的方法注釋中定義,例如: ~~~ <?php namespace app\controller; use think\annotation\Route; use think\annotation\route\Validate; use app\validate\IndexValidate; class Index { /** * @Validate(IndexValidate::class,scene="create",batch="true") * @return mixed * @Route("hello") */ public function hello() { return 'hello, TP6 Annotation Validate'; } } ~~~ `@Route("hello/:name")` 和 `@Validate(IndexValidate::class)` 就是注解路由和驗證器的內容,請務必注意注釋的規范,不能在注解路由里面使用單引號,否則可能導致注解路由解析失敗,可以利用IDE生成規范的注釋。如果你使用`PHPStorm`的話,建議安裝`PHP Annotations`插件:[https://plugins.jetbrains.com/plugin/7320-php-annotations](https://plugins.jetbrains.com/plugin/7320-php-annotations),可以支持注解的自動完成。 然后需要聲明上面引用驗證器類,例如: ~~~ <?php namespace app\validate; use think\Validate; class IndexValidate extends Validate { protected $rule = [ 'name' => 'require' ]; protected $message = [ 'name.require' => '姓名必須填寫', ]; protected $scene = [ 'create' => ['name'], ]; } ~~~ >[danger] 該方式定義的路由在調試模式下面實時生效,部署模式則在第一次訪問的時候生成注解緩存。 ### 注解驗證器參數說明 > `value`參數,可以不寫`value=`,直接抒寫值就可以了 | 參數名 | 參數類型 | 參數默認值 | 參數說明 | | --- | --- | --- | --- | | value | string | | 驗證器 | | scene | string | | 驗證場景 | | batch | bool | true | 統一驗證:true=是,flase=不是 | | message | array | [] | 錯誤內容 | ### 錯誤訪問示例: ~~~ http://127.0.0.1:8000/hello ~~~ 頁面輸出 ![](https://img.kancloud.cn/eb/ca/ebcad4f348acf4c8f734d371ea8a6788_1002x142.png) ### 正確訪問示例: ~~~ http://127.0.0.1:8000/hello?name=zhans ~~~ 頁面輸出 ![](https://img.kancloud.cn/54/9e/549eb02a19ac36e85f816ab32eb7d41d_2334x278.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看