ThinkPHP5最新URL访问:PATH_INFO和兼容模式

https://www.jianshu.com/p/c43fb5817ae1

TP5的url方法生成的是阉割版pathinfo 也就是上面说的第二种。
在config.php第一行加上
\think\Url::root('index.php?s=');
之后就生成的URL是第二种模式。

$request = Request::instance();
echo "当前模块名称是" . $request->module();
echo "当前控制器名称是" . $request->controller();
echo "当前操作名称是" . $request->action();
echo "<Br>";
echo url("HelloWorld/index",'id=5&name=thinkphp').'<br>';
echo url('HelloWorld/index?id=5&name=thinkphp').'<br>';
输出
当前模块名称是index当前控制器名称是HelloWorld当前操作名称是index
index.php?s=/index/hello_world/index/id/5/name/thinkphp
index.php?s=/index/hello_world/index/id/5/name/thinkphp

posted on 2019-05-31 16:43  防空洞123  阅读(1576)  评论(0编辑  收藏  举报

导航