在application /route.php
保存以后项目的路由
同时:application下的index则表示我们有一个index的模块。
其下有一个、index.php我们叫它为控制器。
namespace appindexcontroller;
class Index ThinkPHP V5
{
public function index()
{
return '
十年磨一剑 - 为API开发设计的高性能框架
}
}
我改为:
namespace appindexcontroller;
class Index
{
public function index()
{
return "hello world";
}
public function second(){
> return "hello second";
> }
}
我们 http://localhost:8090/index/index/second
我们修改:
application/route.php
// +----------------------------------------------------------------------
use thinkRoute;
Route::rule('secondroute', 'index/index/second');
http://localhost:8090/secondroute
又看到 hello second 以上的设置我们称之为动态路由
以下是路由配置
// +----------------------------------------------------------------------
use thinkRoute;
//GET POST DELETE PUT , *
Route::rule('first','index/index/first','GEt', ['https'=>true ]);
Route::rule('first','index/index/first','GEt|POST', ['https'=>true ]);
Route::rule('secondroute', 'index/index/second' );
Route::rule('Test/:name/:id', 'index/index/second' );
修改second的内容
public function second($name,$id){
echo $name;
echo "
";
echo $id;
}
http://localhost:8090/Test/whb/199



