Home > Backend Development > PHP Tutorial > PHP框架queryphp课程:入门八 路由跳转

PHP框架queryphp课程:入门八 路由跳转

WBOY
Release: 2016-06-13 11:03:52
Original
936 people have browsed it

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()是加载路径函数
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template