lu-you.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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>路由 · 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="kong-zhi-qi.html" />
  21. <link rel="prev" href="pei-zhi.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="pei-zhi.html">
  42. <a href="pei-zhi.html">
  43. 配置
  44. </a>
  45. </li>
  46. <li class="chapter active" data-level="1.2.2" data-path="lu-you.html">
  47. <a href="lu-you.html">
  48. 路由
  49. </a>
  50. </li>
  51. <li class="chapter " data-level="1.2.3" data-path="kong-zhi-qi.html">
  52. <a href="kong-zhi-qi.html">
  53. 控制器
  54. </a>
  55. </li>
  56. <li class="chapter " data-level="1.2.4" data-path="mo-xing.html">
  57. <a href="mo-xing.html">
  58. 模型
  59. </a>
  60. </li>
  61. <li class="chapter " data-level="1.2.5" data-path="shi-tu.html">
  62. <a href="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 " data-level="1.3.1" data-path="../qi-ta-bu-chong/param.html">
  74. <a href="../qi-ta-bu-chong/param.html">
  75. Param
  76. </a>
  77. </li>
  78. <li class="chapter " data-level="1.3.2" data-path="../qi-ta-bu-chong/tablehelper.html">
  79. <a href="../qi-ta-bu-chong/tablehelper.html">
  80. TableHelper
  81. </a>
  82. </li>
  83. <li class="chapter " data-level="1.3.3" data-path="../qi-ta-bu-chong/ke-zhi-xing-jiao-ben.html">
  84. <a href="../qi-ta-bu-chong/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=".." >路由</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="&#x8DEF;&#x7531;">&#x8DEF;&#x7531;</h3>
  114. <p>&#x8DEF;&#x7531;&#x914D;&#x7F6E;&#x5B9A;&#x4E49;&#x5728;<code>protected/conf/config.inc.php</code>&#x6587;&#x4EF6;&#x7684;<code>$GLOBALS[&apos;rewrite&apos;]</code>&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x3002;</p>
  115. <h6 id="&#x4E0D;&#x5E26;&#x53C2;&#x6570;&#x914D;&#x7F6E;">&#x4E0D;&#x5E26;&#x53C2;&#x6570;&#x914D;&#x7F6E;</h6>
  116. <pre><code class="lang-php">$GLOBALS[<span class="hljs-string">&apos;rewrite&apos;</span>] = [
  117. <span class="hljs-string">&apos;404.html&apos;</span> =&gt; <span class="hljs-string">&apos;default/notFound&apos;</span>,
  118. <span class="hljs-string">&apos;robots.txt&apos;</span> =&gt; <span class="hljs-string">&apos;default/robots&apos;</span>,
  119. ];
  120. </code></pre>
  121. <p>&#x5BF9;&#x5E94;&#x7684;&#x63A5;&#x6536;&#x65B9;&#x6CD5;</p>
  122. <pre><code class="lang-php"> <span class="hljs-comment">// DefaultController</span>
  123. <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">actionRobots</span><span class="hljs-params">($args)</span> </span>{
  124. <span class="hljs-comment">// code</span>
  125. }
  126. </code></pre>
  127. <h6 id="&#x5E26;&#x53C2;&#x6570;&#x914D;&#x7F6E;">&#x5E26;&#x53C2;&#x6570;&#x914D;&#x7F6E;</h6>
  128. <p>&#x652F;&#x6301;<code>&lt;&#x53C2;&#x6570;&#x540D;&gt;</code>&#xFF0C;<code>&lt;&#x53C2;&#x6570;&#x540D;:&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&gt;</code>&#x7684;&#x5199;&#x6CD5;</p>
  129. <pre><code class="lang-php">$GLOBALS[<span class="hljs-string">&apos;rewrite&apos;</span>] = [
  130. <span class="hljs-string">&apos;up_&lt;upId:\d+&gt;/&lt;commentaryId:\d+&gt;.html&apos;</span> =&gt; <span class="hljs-string">&apos;play/commentary&apos;</span>,
  131. ];
  132. </code></pre>
  133. <p>&#x5BF9;&#x5E94;&#x7684;&#x63A5;&#x6536;&#x65B9;&#x6CD5;</p>
  134. <pre><code class="lang-php"><span class="hljs-comment">// PlayController</span>
  135. <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">actionCommentary</span><span class="hljs-params">($args)</span> </span>{
  136. $rules = [
  137. <span class="hljs-string">&apos;commentaryId&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;&#x89E3;&#x8BF4;id&apos;</span>],
  138. <span class="hljs-string">&apos;upId&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;UP&#x4E3B;id&apos;</span>],
  139. ];
  140. Param::checkParam2($rules, $args);
  141. }
  142. </code></pre>
  143. <hr>
  144. <h5 id="url-&#x51FD;&#x6570;">url() &#x51FD;&#x6570;</h5>
  145. <p>url&#x51FD;&#x6570;&#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;&#x8DEF;&#x7531;&#x7684;&#x53CD;&#x5411;&#x5904;&#x7406;&#xFF0C;&#x901A;&#x8FC7;&#x7ED9;&#x5B9A;<code>&#x63A7;&#x5236;&#x5668;/&#x65B9;&#x6CD5;</code>&#x548C;&#x5BF9;&#x5E94;&#x7684;&#x53C2;&#x6570;&#x751F;&#x6210;&#x5BF9;&#x5E94;&#x7684;url&#x3002;</p>
  146. <p>&#x8003;&#x8651;&#x5230;&#x8DEF;&#x7531;&#x89C4;&#x5219;&#x7684;&#x4FEE;&#x6539;&#xFF0C;&#x57DF;&#x540D;&#x8C03;&#x6574;&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x4E0D;&#x5EFA;&#x8BAE;&#x786C;&#x7F16;&#x7801;url,&#x800C;&#x4F7F;&#x7528;url&#x51FD;&#x6570;&#x751F;&#x6210;&#x3002;</p>
  147. <p>&#x4EE5;&#x4E0A;&#x9762;<code>play/commentary</code>&#x4E3A;&#x4F8B;</p>
  148. <pre><code class="lang-php">url(<span class="hljs-string">&apos;play/commentary&apos;</span>, [<span class="hljs-string">&apos;upId&apos;</span> =&gt; <span class="hljs-number">1</span>, <span class="hljs-string">&apos;commentaryId&apos;</span> =&gt; <span class="hljs-number">100</span>]);
  149. <span class="hljs-comment">// output: </span>
  150. <span class="hljs-comment">// http://HOST/up_1/100.html</span>
  151. </code></pre>
  152. </section>
  153. </div>
  154. <div class="search-results">
  155. <div class="has-results">
  156. <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
  157. <ul class="search-results-list"></ul>
  158. </div>
  159. <div class="no-results">
  160. <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. <a href="pei-zhi.html" class="navigation navigation-prev " aria-label="Previous page: 配置">
  168. <i class="fa fa-angle-left"></i>
  169. </a>
  170. <a href="kong-zhi-qi.html" class="navigation navigation-next " aria-label="Next page: 控制器">
  171. <i class="fa fa-angle-right"></i>
  172. </a>
  173. </div>
  174. <script>
  175. var gitbook = gitbook || [];
  176. gitbook.push(function() {
  177. gitbook.page.hasChanged({"page":{"title":"路由","level":"1.2.2","depth":2,"next":{"title":"控制器","level":"1.2.3","depth":2,"path":"chapter1/kong-zhi-qi.md","ref":"chapter1/kong-zhi-qi.md","articles":[]},"previous":{"title":"配置","level":"1.2.1","depth":2,"path":"chapter1/pei-zhi.md","ref":"chapter1/pei-zhi.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":"chapter1/lu-you.md","mtime":"2018-09-07T09:22:05.757Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-09-13T03:13:15.790Z"},"basePath":"..","book":{"language":""}});
  178. });
  179. </script>
  180. </div>
  181. <script src="../gitbook/gitbook.js"></script>
  182. <script src="../gitbook/theme.js"></script>
  183. <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
  184. <script src="../gitbook/gitbook-plugin-search/search.js"></script>
  185. <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
  186. <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
  187. <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
  188. <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
  189. </body>
  190. </html>