zoukankan      html  css  js  c++  java
  • Ubuntu使用——15(thinkphp路由报错Non-static method thinkRoute::get() should not be called statically)

    在route.php中添加代码:

    use thinkRoute;
    Route::get('/',function (){
        return 'hello world';
    });

    在浏览器中输入http://localhost/tp5-git/public/index.php,报错:

    [8192] ErrorException in route.php line 13
    Non-static method thinkRoute::get() should not be called statically
    // +----------------------------------------------------------------------
    // | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
    // +----------------------------------------------------------------------
    // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
    // +----------------------------------------------------------------------
    // | Author: liu21st <liu21st@gmail.com>
    // +----------------------------------------------------------------------
    
    use thinkRoute;
    Route::get('/',function (){
        return 'hello world';
    });
    Route::get('think', function () {
        return 'hello,ThinkPHP5!';
    });
    
    Route::get('hello/:name', 'index/hello');
    
    return [

    解决方法是:注释掉“use thinkRoute;”即可。

    成功界面:

    思考:观察route.php中自带的代码,发现他们都没有“use thinkRoute;”,在网上搜索没有找到明确的解决方案,但仔细思考,可能就是“use thinkRoute;”的问题,注释掉果真成功了。

  • 相关阅读:
    算法(Algorithms)第4版 练习 1.5.22
    基于RPC原理的dubbo
    java的动态代理机制详解
    xxxx interview
    mysql创建账号
    elasticsearch搜索集群基础架构
    zookeeper可视化管理工具node-zk-browser安装
    kafka监控搭建
    kafka集群安装
    zookeeper集群安装
  • 原文地址:https://www.cnblogs.com/wangjianupc/p/10587175.html
Copyright © 2011-2022 走看看