PHP架構queryphp課程:入門八 路由跳轉

來源:互聯網
上載者:User
PHP架構queryphp教程:入門八 路由跳轉

路由說明

path_info方式

testframework.php?router=default&action=index

testframework.php/default/index?

可以使用apache重寫 去掉testframework.php檔案

可以自己設定路由規則

C("router")->ruleMaps("login",'/login/:id', array('controller' => 'auth', 'action' => 'login'));

那麼會配匹testframework.php/login/5555

這樣可以使用$_GET['id']得到5555;

'controller' => 'auth', 'action' => 'login'

是控制器和方法

其它設定 可以添加自己定義的路由規則:

C("router")->ruleMaps('logout','/logout', array('controller' => 'auth', 'action' => 'logout'));

C("router")->ruleMaps('signup','/signup', array('controller' => 'auth', 'action' => 'signup'));

C("router")->ruleMaps('profile','/profile/:action', array('controller' => 'profile')); // will call controller "Profile" with dynamic method ":action()"

C("router")->ruleMaps('users','/users/:id', array('controller' => 'users'), array('id' => '[\d]{1,8}')); // define filters for the url parameters

支援path_info方式

控制動作在router目錄下面

/default/index

調用router目錄下面defaultRouter.class.php檔案

取得類後調用index方式

  • J()是index方法跳轉
  • R()是由控制
  • C()是產生類
  • M()是資料庫類模型?
  • P()是載入路徑函數
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.