use think\route 问题
来源:3-4 三种URL访问模式
朴自然华子
2017-07-03
在建立路由用Route的时候,如果加了这行代码,use think\Route,就会报错,下面这个图所示,配置路由不成功,访问页面不成功。
但如果去掉这一行代码,Route那里也会报错,说是未定义,但是访问页面是成功的。
这个问题在后面的Request方法也遇到类似的问题,导致Request::instance() ->param()的方法也用不成功,这是什么问题?是版本问题还是什么?研究一天了,找不出问题,老师救救我。
写回答
5回答
-
为什么你的route有一个route文件夹?这应该是新版本,课程开始的时候强调了,最好跟课程的TP版本保持一致啊,同学。当然如果你有能力,可以用最新的版本,不过会遇到很多问题,而且新版本意义并不大。
032017-07-04 -
7七月
2017-07-04
还好我看出来了,如果不是刚好这里route有个文件夹,我估计我也看不出来,你用的不是5.07版本
00 -
朴自然华子
提问者
2017-07-04
另外在代码里有自动出现提示 (hint)的东西,去不掉,可以隐藏,但无法删除,不知道和这个有没有关系。
00 -
朴自然华子
提问者
2017-07-04
报错信息如下:
[8192] ErrorException in route.php line 13 Non-static method think\Route::get() should not be called statically, assuming $this from incompatible context // +----------------------------------------------------------------------// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.// +----------------------------------------------------------------------// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )// +----------------------------------------------------------------------// | Author: liu21st <liu21st@gmail.com>// +----------------------------------------------------------------------think\route\Rule::use think\Route;Route::get('hello','sample/Test/hello'); Call Stack in route.php line 13 at Error::appError(8192, 'Non-static method th...', 'D:\xampp\htdocs\zerg...', 13, ['path' => 'hello', 'depr' => '/', 'files' => ['.', '..', 'route.php'], ...]) in route.php line 13 at include('D:\xampp\htdocs\zerg...') in App.php line 385 at App->routeCheck(object(Request)) in App.php line 285 at App->run() in start.php line 21 at require('D:\xampp\htdocs\zerg...') in index.php line 17 Exception Datas Error Context path hello depr / files [ ".", "..", "route.php" ] file route.php filename D:\xampp\htdocs\zerg/route/\route.php Environment Variables GET Dataempty POST Dataempty Filesempty Cookies pgv_pvi 717815808 Sessionempty Server/Request Data REDIRECT_MIBDIRS D:/xampp/php/extras/mibs REDIRECT_MYSQL_HOME \xampp\mysql\bin REDIRECT_OPENSSL_CONF D:/xampp/apache/bin/openssl.cnf REDIRECT_PHP_PEAR_SYSCONF_DIR \xampp\php REDIRECT_PHPRC \xampp\php REDIRECT_TMP \xampp\tmp REDIRECT_STATUS 200 MIBDIRS D:/xampp/php/extras/mibs MYSQL_HOME \xampp\mysql\bin OPENSSL_CONF D:/xampp/apache/bin/openssl.cnf PHP_PEAR_SYSCONF_DIR \xampp\php PHPRC \xampp\php TMP \xampp\tmp HTTP_HOST z.cn HTTP_CONNECTION keep-alive HTTP_UPGRADE_INSECURE_REQUESTS 1 HTTP_USER_AGENT Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 HTTP_ACCEPT_ENCODING gzip, deflate HTTP_ACCEPT_LANGUAGE zh-CN,zh;q=0.8 HTTP_COOKIE pgv_pvi=717815808 PATH C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\bin\Intel64;C:\Program Files\Java\jdk1.8.0_131\bin;C:\Program Files\Java\jdk1.8.0_131\jre\bin;D:\AppData\Local\Android\Sdk\tools\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;D:\Program Files (x86)\Skype\Phone\;D:\Android\Sdk\tools\;D:\Android\Sdk\platform-tools\;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;D:\softwarebackup\eclipse-jee-mars-2-win32-x86_64\eclipse\;D:\Android\Sdk\platform-tools\;D:\Android\Sdk;D:\xampp\php\;D:\xampp\php\ SystemRoot C:\WINDOWS COMSPEC C:\WINDOWS\system32\cmd.exe PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC WINDIR C:\WINDOWS SERVER_SIGNATURE <address>Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 Server at z.cn Port 80</address> SERVER_SOFTWARE Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 SERVER_NAME z.cn SERVER_ADDR 127.0.0.1 SERVER_PORT 80 REMOTE_ADDR 127.0.0.1 DOCUMENT_ROOT D:/xampp/htdocs/zerg/public REQUEST_SCHEME http CONTEXT_PREFIX CONTEXT_DOCUMENT_ROOT D:/xampp/htdocs/zerg/public SERVER_ADMIN postmaster@localhost SCRIPT_FILENAME D:/xampp/htdocs/zerg/public/index.php REMOTE_PORT 61360 REDIRECT_URL /hello GATEWAY_INTERFACE CGI/1.1 SERVER_PROTOCOL HTTP/1.1 REQUEST_METHOD GET QUERY_STRING REQUEST_URI /hello SCRIPT_NAME /index.php PATH_INFO /hello PATH_TRANSLATED redirect:\index.php\hello PHP_SELF /index.php/hello REQUEST_TIME_FLOAT 1499098786.552 REQUEST_TIME 1499098786 Environment Variablesempty ThinkPHP Constants APP_PATH D:\xampp\htdocs\zerg\public/../application/ ThinkPHP V5.1.0beta { 十年磨一剑-为API开发设计的高性能框架 }
012017-07-04 -
7七月
2017-07-04
use think\Route,就会报错。。。。贴一下错误信息啊,我感觉这个命名空间好奇怪
022018-08-02
相似问题