<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>

                ## URL訪問 `ThinkPHP`采用單一入口模式訪問應用,對應用的所有請求都定向到應用的入口文件,系統會從`URL`參數中解析當前請求的模塊、控制器和操作,下面是一個標準的`URL`訪問格式: ~~~ http://domainName/index.php/模塊/控制器/操作 ~~~ 其中`index.php`就稱之為應用的入口文件(注意入口文件可以被隱藏,后面會提到)。 >[success]#### 提示: > * * * * * > 模塊在ThinkPHP中的概念其實就是應用目錄下面的子目錄,而官方的規范是目錄名小寫,因此模塊全部采用小寫命名,無論URL是否開啟大小寫轉換,模塊名都會強制小寫。 應用的`index`模塊的`Index`控制器定義如下: ~~~ <?php namespace app\index\controller; class Index { public function index() { return 'index'; } public function hello($name = 'World') { return 'Hello,' . $name . '!'; } } ~~~ 如果我們直接訪問入口文件的話,由于URL中沒有模塊、控制器和操作,因此系統會訪問默認模塊(index)下面的默認控制器(Index)的默認操作(index),因此下面的訪問是等效的: ~~~ http://tp5.com/index.php http://tp5.com/index.php/index/index/index ~~~ 如果要訪問控制器的hello方法,則需要使用完整的URL地址 ~~~ http://tp5.com/index.php/index/index/hello/name/thinkphp ~~~ 訪問URL地址后頁面輸出結果為: ~~~ Hello,thinkphp! ~~~ 由于`name`參數為可選參數,因此也可以使用 ~~~ http://tp5.com/index.php/index/index/hello ~~~ 訪問URL地址后頁面輸出結果為: ~~~ Hello,World! ~~~ 默認情況下,URL地址中的控制器和操作名是不區分大小寫的,因此下面的訪問其實是等效的: ~~~ http://tp5.com/index.php/index/Index/Index http://tp5.com/index.php/index/INDEX/INDEX ~~~ 如果你的控制器是駝峰的,例如定義一個HelloWorld控制器(`application/index/controller/HelloWorld.php`): ~~~ <?php namespace app\index\controller; class HelloWorld { public function index($name = 'World') { return 'Hello,' . $name . '!'; } } ~~~ 正確的URL訪問地址(該地址可以使用url方法生成)應該是: ~~~ http://tp5.com/index.php/index/hello_world/index ~~~ 系統會自動定位到`HelloWorld`控制器類去操作。 如果使用 ~~~ http://tp5.com/index.php/index/HelloWorld/index ~~~ 將會報錯,并提示`Helloworld`控制器類不存在。 如果希望嚴格區分大小寫訪問(這樣就可以支持駝峰法進行控制器訪問),可以在應用配置文件中設置: ~~~ // 關閉URL自動轉換(支持駝峰訪問控制器) 'url_convert' => false, ~~~ 關閉URL自動轉換之后,必須使用下面的URL地址訪問(控制器名稱必須嚴格使用控制器類的名稱,不包含控制器后綴): ~~~ http://tp5.com/index.php/index/Index/index http://tp5.com/index.php/index/HelloWorld/index ~~~ >[success]#### 提示: > * * * * * > 操作方法的訪問本身不會受URL自動轉換的影響,但會影響默認的模板渲染輸出。 如果你的服務器環境不支持`pathinfo`方式的URL訪問,可以使用兼容方式,例如: ~~~ http://tp5.com/index.php?s=/index/Index/index ~~~ 其中變量`s`的名稱的可以配置的。 > 5.0不再支持普通的URL訪問方式,所以下面的訪問是無效的,你會發現無論輸入什么,訪問的都是默認的控制器和操作^_^ ~~~ http://tp5.com/index.php?m=index&c=Index&a=hello ~~~
                  <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>

                              哎呀哎呀视频在线观看