param.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <!DOCTYPE HTML>
  2. <html lang="" >
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  6. <title>Param · GitBook</title>
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  8. <meta name="description" content="">
  9. <meta name="generator" content="GitBook 3.2.3">
  10. <link rel="stylesheet" href="../gitbook/style.css">
  11. <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
  12. <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
  13. <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
  14. <meta name="HandheldFriendly" content="true"/>
  15. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  16. <meta name="apple-mobile-web-app-capable" content="yes">
  17. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  18. <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
  19. <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
  20. <link rel="next" href="tablehelper.html" />
  21. <link rel="prev" href="../qi-ta-bu-chong.html" />
  22. </head>
  23. <body>
  24. <div class="book">
  25. <div class="book-summary">
  26. <div id="book-search-input" role="search">
  27. <input type="text" placeholder="Type to search" />
  28. </div>
  29. <nav role="navigation">
  30. <ul class="summary">
  31. <li class="chapter " data-level="1.1" data-path="../">
  32. <a href="../">
  33. 简介
  34. </a>
  35. </li>
  36. <li class="chapter " data-level="1.2" data-path="../chapter1.html">
  37. <a href="../chapter1.html">
  38. 基础用法
  39. </a>
  40. <ul class="articles">
  41. <li class="chapter " data-level="1.2.1" data-path="../chapter1/pei-zhi.html">
  42. <a href="../chapter1/pei-zhi.html">
  43. 配置
  44. </a>
  45. </li>
  46. <li class="chapter " data-level="1.2.2" data-path="../chapter1/lu-you.html">
  47. <a href="../chapter1/lu-you.html">
  48. 路由
  49. </a>
  50. </li>
  51. <li class="chapter " data-level="1.2.3" data-path="../chapter1/kong-zhi-qi.html">
  52. <a href="../chapter1/kong-zhi-qi.html">
  53. 控制器
  54. </a>
  55. </li>
  56. <li class="chapter " data-level="1.2.4" data-path="../chapter1/mo-xing.html">
  57. <a href="../chapter1/mo-xing.html">
  58. 模型
  59. </a>
  60. </li>
  61. <li class="chapter " data-level="1.2.5" data-path="../chapter1/shi-tu.html">
  62. <a href="../chapter1/shi-tu.html">
  63. 视图
  64. </a>
  65. </li>
  66. </ul>
  67. </li>
  68. <li class="chapter " data-level="1.3" data-path="../qi-ta-bu-chong.html">
  69. <a href="../qi-ta-bu-chong.html">
  70. 其他补充
  71. </a>
  72. <ul class="articles">
  73. <li class="chapter active" data-level="1.3.1" data-path="param.html">
  74. <a href="param.html">
  75. Param
  76. </a>
  77. </li>
  78. <li class="chapter " data-level="1.3.2" data-path="tablehelper.html">
  79. <a href="tablehelper.html">
  80. TableHelper
  81. </a>
  82. </li>
  83. <li class="chapter " data-level="1.3.3" data-path="ke-zhi-xing-jiao-ben.html">
  84. <a href="ke-zhi-xing-jiao-ben.html">
  85. 可执行脚本
  86. </a>
  87. </li>
  88. </ul>
  89. </li>
  90. <li class="divider"></li>
  91. <li>
  92. <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
  93. Published with GitBook
  94. </a>
  95. </li>
  96. </ul>
  97. </nav>
  98. </div>
  99. <div class="book-body">
  100. <div class="body-inner">
  101. <div class="book-header" role="navigation">
  102. <!-- Title -->
  103. <h1>
  104. <i class="fa fa-circle-o-notch fa-spin"></i>
  105. <a href=".." >Param</a>
  106. </h1>
  107. </div>
  108. <div class="page-wrapper" tabindex="-1" role="main">
  109. <div class="page-inner">
  110. <div id="book-search-results">
  111. <div class="search-noresults">
  112. <section class="normal markdown-section">
  113. <h3 id="param">Param</h3>
  114. <p><code>Param</code>&#x4E3A;&#x6211;&#x4EEC;&#x63D0;&#x4F9B;&#x4E86;&#x4E30;&#x5BCC;&#x7684;&#x53C2;&#x6570;&#x6821;&#x9A8C;&#x89C4;&#x5219;&#x3002;</p>
  115. <h6 id="&#x57FA;&#x7840;&#x914D;&#x7F6E;">&#x57FA;&#x7840;&#x914D;&#x7F6E;</h6>
  116. <p>&#x9700;&#x8981;&#x5305;&#x542B;<code>type(&#x7C7B;&#x578B;)</code>&#x548C;<code>desc(&#x63CF;&#x8FF0;)</code>&#xFF0C;&#x63CF;&#x8FF0;&#x4F7F;&#x63A5;&#x53E3;&#x53C2;&#x6570;&#x542B;&#x4E49;&#x66F4;&#x6E05;&#x6670;&#xFF0C;&#x540C;&#x65F6;&#x751F;&#x6210;&#x6587;&#x6863;&#x65F6;&#x6628;&#x665A;&#x53C2;&#x6570;&#x8BF4;&#x660E;&#x3002;</p>
  117. <pre><code class="lang-php">$rules = [
  118. <span class="hljs-string">&apos;id&apos;</span> =&gt; [<span class="hljs-string">&apos;type&apos;</span> =&gt; <span class="hljs-string">&apos;int&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x7528;&#x6237;id&apos;</span>],
  119. ];
  120. <span class="hljs-comment">// &#x5F53;type&#x4F4D;&#x4E8E;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x65F6;&#xFF0C;&#x53EF;&#x7F29;&#x5199;&#x4E3A;</span>
  121. $rules = [
  122. <span class="hljs-string">&apos;id&apos;</span> =&gt; [<span class="hljs-string">&apos;int&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x7528;&#x6237;id&apos;</span>],
  123. ];
  124. </code></pre>
  125. <h6 id="&#x7C7B;&#x578B;&#x652F;&#x6301;">&#x7C7B;&#x578B;&#x652F;&#x6301;</h6>
  126. <p><code>type</code>&#x652F;&#x6301;<code>int</code>&#xFF0C;<code>string</code>&#xFF0C;<code>array</code>&#xFF0C;<code>float</code>&#xFF0C;<code>ip</code>&#xFF0C;<code>intArr</code>(array&#x7C7B;&#x578B;&#xFF0C;&#x5143;&#x7D20;&#x4E3A;int&#x7C7B;&#x578B;)&#xFF0C;<code>strArr</code>(array&#x7C7B;&#x578B;&#xFF0C;&#x5143;&#x7D20;&#x4E3A;string&#x7C7B;&#x578B;)&#xFF0C;<code>ipArr</code>(array&#x7C7B;&#x578B;&#xFF0C;&#x5143;&#x7D20;&#x4E3A;ip&#x7C7B;&#x578B;)&#xFF1B;&#x5E76;&#x4E14;&#x652F;&#x6301;<code>&#x6216;</code>&#x7EC4;&#x5408;&#x3002;</p>
  127. <pre><code class="lang-php">$rules = [
  128. <span class="hljs-comment">// id&#x53EF;&#x80FD;&#x4E3A;int&#x6216;&#x8005;string&#x7C7B;&#x578B;</span>
  129. <span class="hljs-string">&apos;id&apos;</span> =&gt; [<span class="hljs-string">&apos;int/string&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x4E1A;&#x52A1;id&apos;</span>], <span class="hljs-comment">// id&#x53EF;&#x80FD;&#x4E3A;int&#x6216;&#x8005;string</span>
  130. ];
  131. </code></pre>
  132. <h6 id="&#x679A;&#x4E3E;&#x652F;&#x6301;">&#x679A;&#x4E3E;&#x652F;&#x6301;</h6>
  133. <p>&#x914D;&#x7F6E;<code>enum</code>key&#x652F;&#x6301;&#x679A;&#x4E3E;&#x503C;</p>
  134. <pre><code class="lang-php">$rules = [
  135. <span class="hljs-string">&apos;value&apos;</span> =&gt; [<span class="hljs-string">&apos;int&apos;</span>, <span class="hljs-string">&apos;enum&apos;</span> =&gt; [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>], <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x66F4;&#x65B0;&#x503C;&apos;</span>],
  136. <span class="hljs-string">&apos;field&apos;</span> =&gt; [<span class="hljs-string">&apos;string&apos;</span>, <span class="hljs-string">&apos;enum&apos;</span> =&gt; [<span class="hljs-string">&apos;field1&apos;</span>, <span class="hljs-string">&apos;field2&apos;</span>], <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x66F4;&#x65B0;&#x5B57;&#x6BB5;&apos;</span>],
  137. ];
  138. </code></pre>
  139. <h6 id="&#x533A;&#x95F4;&#x652F;&#x6301;">&#x533A;&#x95F4;&#x652F;&#x6301;</h6>
  140. <p><code>int</code>,<code>float</code>&#x6570;&#x503C;&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x914D;&#x7F6E;<code>range</code>&#x652F;&#x6301;&#x533A;&#x95F4;&#x9650;&#x5236;</p>
  141. <pre><code class="lang-php">$rules = [
  142. <span class="hljs-comment">// &#x5168;&#x95ED;&#x5408;</span>
  143. <span class="hljs-string">&apos;num&apos;</span> =&gt; [<span class="hljs-string">&apos;int&apos;</span>, <span class="hljs-string">&apos;range&apos;</span> =&gt; <span class="hljs-string">&apos;[1,10]&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x53F7;&#x7801;&apos;</span>],
  144. <span class="hljs-comment">// &#x534A;&#x95ED;&#x5408;</span>
  145. <span class="hljs-string">&apos;weight&apos;</span> =&gt; [<span class="hljs-string">&apos;float&apos;</span>, <span class="hljs-string">&apos;range&apos;</span> =&gt; <span class="hljs-string">&apos;(0,200.1]&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x4F53;&#x91CD;&apos;</span>],
  146. <span class="hljs-comment">// &#x4E0D;&#x95ED;&#x5408;</span>
  147. <span class="hljs-string">&apos;height&apos;</span> =&gt; [<span class="hljs-string">&apos;float&apos;</span>, <span class="hljs-string">&apos;range&apos;</span> =&gt; <span class="hljs-string">&apos;(50.5,250.1)&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x8EAB;&#x9AD8;&apos;</span>],
  148. ];
  149. </code></pre>
  150. <h6 id="&#x957F;&#x5EA6;&#x652F;&#x6301;">&#x957F;&#x5EA6;&#x652F;&#x6301;</h6>
  151. <p><code>string</code>&#x7C7B;&#x578B;&#x914D;&#x7F6E;<code>len</code>&#x652F;&#x6301;&#x957F;&#x5EA6;&#x9650;&#x5236;&#xFF0C;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x548C;<code>range</code>&#x7C7B;&#x4F3C;</p>
  152. <pre><code class="lang-php">$rules = [
  153. <span class="hljs-string">&apos;nick&apos;</span> =&gt; [<span class="hljs-string">&apos;string&apos;</span>, <span class="hljs-string">&apos;len&apos;</span> =&gt; <span class="hljs-string">&apos;[4,11)&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x6635;&#x79F0;&apos;</span>],
  154. ];
  155. </code></pre>
  156. <p>&#x6B63;&#x5219;&#x652F;&#x6301;</p>
  157. <p><code>string</code>&#x7C7B;&#x578B;&#x914D;&#x7F6E;<code>reg</code>&#x652F;&#x6301;&#x6B63;&#x5219;&#x6821;&#x9A8C;&#x3002;</p>
  158. <pre><code class="lang-php">$rules = [
  159. <span class="hljs-string">&apos;username&apos;</span> =&gt; [<span class="hljs-string">&apos;string&apos;</span>, <span class="hljs-string">&apos;reg&apos;</span> =&gt; <span class="hljs-string">&apos;[^0-9A-Za-z]&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x7528;&#x6237;&#x540D;&apos;</span>],
  160. ];
  161. </code></pre>
  162. <h6 id="emptyablenullable&#x5F00;&#x5173;">emptyable/nullable&#x5F00;&#x5173;</h6>
  163. <p><code>emptyable</code>&#x8BBE;&#x7F6E;&#x4E3A;<code>true</code>&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53C2;&#x6570;&#x5141;&#x8BB8;&#x7A7A;&#x503C;&#xFF08;<code>string</code>&#x7C7B;&#x578B;&#x7684;&#x53C2;&#x6570;<code>&amp;nick=</code>&#xFF09;&#xFF1B;<code>nullable</code>&#x8BBE;&#x7F6E;&#x4E3A;<code>true</code>&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x7F3A;&#x7701;&#xFF0C;&#x8FD9;&#x65F6;&#x53EF;&#x4EE5;&#x914D;&#x5408;<code>default</code>&#x8BBE;&#x7F6E;&#x9ED8;&#x8BA4;&#x503C;&#x3002;</p>
  164. <pre><code class="lang-php">$rules = [
  165. <span class="hljs-string">&apos;nick&apos;</span> =&gt; [<span class="hljs-string">&apos;string&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x6635;&#x79F0;&apos;</span>],
  166. ];
  167. <span class="hljs-comment">// input: &amp;nick=</span>
  168. <span class="hljs-comment">// outpuy: param error</span>
  169. $rules = [
  170. <span class="hljs-string">&apos;nick&apos;</span> =&gt; [<span class="hljs-string">&apos;string&apos;</span>, <span class="hljs-string">&apos;emptyable&apos;</span> =&gt; <span class="hljs-keyword">true</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x6635;&#x79F0;&apos;</span>],
  171. ];
  172. <span class="hljs-comment">// input: &amp;nick=</span>
  173. <span class="hljs-comment">// outpuy: [&apos;nick&apos; =&gt; &apos;&apos;]</span>
  174. $rules = [
  175. <span class="hljs-string">&apos;nick&apos;</span> =&gt; [<span class="hljs-string">&apos;string&apos;</span>, <span class="hljs-string">&apos;nullable&apos;</span> =&gt; <span class="hljs-keyword">true</span>, <span class="hljs-string">&apos;default&apos;</span> =&gt; <span class="hljs-string">&apos;solu&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x6635;&#x79F0;&apos;</span>],
  176. ];
  177. <span class="hljs-comment">// input: &amp;nick= or &#x4E0D;&#x4F20;&#x53C2;</span>
  178. <span class="hljs-comment">// outpuy: [&apos;nick&apos; =&gt; &apos;solu&apos;]</span>
  179. </code></pre>
  180. <h6 id="&#x53C2;&#x6570;&#x540D;&#x901A;&#x914D;&#x7B26;&#x652F;&#x6301;">&#x53C2;&#x6570;&#x540D;&#x901A;&#x914D;&#x7B26;&#x652F;&#x6301;</h6>
  181. <p>&#x540C;&#x4E00;&#x7C7B;&#x578B;&#x4E0D;&#x786E;&#x5B9A;&#x53C2;&#x6570;&#x4E2A;&#x6570;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x53C2;&#x6570;&#x540D;&#x7684;&#x901A;&#x914D;&#x7B26;&#x8FDB;&#x884C;&#x914D;&#x7F6E;</p>
  182. <pre><code class="lang-php">$rules = [
  183. <span class="hljs-string">&apos;num_*&apos;</span> =&gt; [<span class="hljs-string">&apos;int&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x53F7;&#x7801;&apos;</span>],
  184. ];
  185. <span class="hljs-comment">// input: &amp;num_1=1&amp;num_2=2&amp;num_5=5 ...</span>
  186. <span class="hljs-comment">// output: [&apos;num_1&apos; =&gt; 1, &apos;num_2&apos; =&gt; 2, &apos;num_3&apos; =&gt; 3]</span>
  187. </code></pre>
  188. </section>
  189. </div>
  190. <div class="search-results">
  191. <div class="has-results">
  192. <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
  193. <ul class="search-results-list"></ul>
  194. </div>
  195. <div class="no-results">
  196. <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203. <a href="../qi-ta-bu-chong.html" class="navigation navigation-prev " aria-label="Previous page: 其他补充">
  204. <i class="fa fa-angle-left"></i>
  205. </a>
  206. <a href="tablehelper.html" class="navigation navigation-next " aria-label="Next page: TableHelper">
  207. <i class="fa fa-angle-right"></i>
  208. </a>
  209. </div>
  210. <script>
  211. var gitbook = gitbook || [];
  212. gitbook.push(function() {
  213. gitbook.page.hasChanged({"page":{"title":"Param","level":"1.3.1","depth":2,"next":{"title":"TableHelper","level":"1.3.2","depth":2,"path":"qi-ta-bu-chong/tablehelper.md","ref":"qi-ta-bu-chong/tablehelper.md","articles":[]},"previous":{"title":"其他补充","level":"1.3","depth":1,"path":"qi-ta-bu-chong.md","ref":"qi-ta-bu-chong.md","articles":[{"title":"Param","level":"1.3.1","depth":2,"path":"qi-ta-bu-chong/param.md","ref":"qi-ta-bu-chong/param.md","articles":[]},{"title":"TableHelper","level":"1.3.2","depth":2,"path":"qi-ta-bu-chong/tablehelper.md","ref":"qi-ta-bu-chong/tablehelper.md","articles":[]},{"title":"可执行脚本","level":"1.3.3","depth":2,"path":"qi-ta-bu-chong/ke-zhi-xing-jiao-ben.md","ref":"qi-ta-bu-chong/ke-zhi-xing-jiao-ben.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"qi-ta-bu-chong/param.md","mtime":"2018-09-13T03:12:45.788Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-09-13T03:13:15.790Z"},"basePath":"..","book":{"language":""}});
  214. });
  215. </script>
  216. </div>
  217. <script src="../gitbook/gitbook.js"></script>
  218. <script src="../gitbook/theme.js"></script>
  219. <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
  220. <script src="../gitbook/gitbook-plugin-search/search.js"></script>
  221. <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
  222. <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
  223. <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
  224. <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
  225. </body>
  226. </html>