Non-static method think\DbManager::connect() should not be called statically
namespace?app\controller;use?app\BaseController;use?think\Db;class?Index?extends?BaseController?{ public?function?index($name?=?'Keith',?$age?=?28)?{ //?return?'hello?'?.?$name?.?'?I\'m?'?.?$age; //?dump(config("database")); try?{ $res?=?Db::connect(); //?$res?=?[]; dump($res); }?catch?(Exception?$e)?{ dump($e); echo?"異常了"; } } public?function?hello($name?=?'ThinkPHP6')?{ return?'hello,'?.?$name; }}
2019-12-24
作者使用的是5.0的,我使用的是6.0,在6.0下,ues think\facade\Db; 這樣就ok了