控制器 demo.phpn内容
<?php
namespace app\index\controller;
class Demo
{
public function add($n,$m)
{
return $n.'+'.$m.'='.($n+$m);
}
public function sub($n,$m)
{
return $n.'-'.$m.'='.($n-$m);
}
public function mul($n,$m)
{
return $n.'*'.$m.'='.($n*$m);
}
public function div($n,$m)
{
return $n.'/'.$m.'='.round(($n/$m),2);
}
}route.php文件内容
//绑定的命名空间 http://www.tp5.com/demo/div/1/1
think\Route::bind('app\index\controller','namespace');
//绑定到类 http://www.tp5.com/div/1/1
think\Route::bind('app\index\controller\Demo','class');
//绑定到模块 http://www.tp5.com/demo/add/1/1
think\Route::bind('index');
//绑定到控制器 http://www.tp5.com/add/1/1
think\Route::bind('index/Demo');
//绑定到操作 http://www.tp5.com//1/1
think\Route::bind('index/Demo/add');
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号