Hello, what's going on when it prompts syntax error, unexpected ':', expecting ',' or ')'?
雨
2019-05-26 15:47:42
0
2
5598

[0] ParseError in Index.php line 10

syntax error, unexpected ':', expecting ',' or ')'

<?phpnamespace app\index\controller;use think\facade\Db;class Index{    public function index()    {        dump(Db::query(sql:'SELECT * FROM 'user' LIMI 1'));    }    public function hello($name = 'ThinkPHP6')    {        return 'hello,' . $name;    }}

Call Stack

in Index.php line 10

at Composer\Autoload\includeFile('D:\myphp_www\PHPTuto...') in ClassLoader.php line 322

at ClassLoader->loadClass('app\index\controller...')

at spl_autoload_call('app\index\controller...')

at class_exists('app\index\controller...') in Controller.php line 103

at Controller->controller('index') in Controller.php line 57

at Controller->exec() in Dispatch.php line 118

at Dispatch->run() in Route.php line 748

at Route->think\{closure}(object(Request), object(Closure), null)

at call_user_func_array(object(Closure), [object(Request), object(Closure), null]) in Middleware.php line 206

at Middleware->think\{closure}(object(Request)) in TraceDebug.php line 48

at TraceDebug->handle(object(Request), object(Closure), null)

at call_user_func_array([object(TraceDebug), 'handle'], [object(Request), object(Closure), null]) in Middleware.php line 206

at Middleware->think\{closure}(object(Request)) in SessionInit.php line 58

at SessionInit->handle(object(Request), object(Closure), null)

at call_user_func_array([object(SessionInit), 'handle'], [object(Request), object(Closure), null]) in Middleware.php line 206

at Middleware->think\{closure}(object(Request)) in LoadLangPack.php line 60

at LoadLangPack->handle(object(Request), object(Closure), null)

at call_user_func_array([object(LoadLangPack), 'handle'], [object(Request), object(Closure), null]) in Middleware.php line 206

at Middleware->think\{closure}(object(Request)) in CheckRequestCache.php line 53

at CheckRequestCache->handle(object(Request), object(Closure), null)

at call_user_func_array([object(CheckRequestCache), 'handle'], [object(Request), object(Closure), null]) in Middleware.php line 206

at Middleware->think\{closure}(object(Request))

at call_user_func(object(Closure), object(Request)) in Middleware.php line 150

at Middleware->dispatch(object(Request)) in Route.php line 755

at Route->dispatch(object(Request), object(Closure)) in Http.php line 187

at Http->runWithRequest(object(Request)) in Http.php line 139

at Http->run() in index.php line 20

Environment Variables

GET Data

/index/index    

POST Dataempty

Filesempty

Cookies

PHPSESSID    a334386e8fff32d2936329a874461407    

pgv_pvi    4820957184    

pgv_si    s5068664832    

thinkphp_show_page_trace    0|0    

Sessionempty

Server/Request Data

PATH    C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\WINDOWS\System32\OpenSSH\;C:\Users\gznet\AppData\Local\Microsoft\WindowsApps    

SYSTEMROOT    C:\WINDOWS    

COMSPEC    C:\WINDOWS\system32\cmd.exe    

PATHEXT    .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC    

WINDIR    C:\WINDOWS    

PHP_FCGI_MAX_REQUESTS    1000    

PHPRC    D:/myphp_www/PHPTutorial/php/php-7.2.1-nts/    

_FCGI_SHUTDOWN_EVENT_    2240    

SCRIPT_NAME    /index.php    

REQUEST_URI    /index/index    

QUERY_STRING    /index/index    

REQUEST_METHOD    GET    

SERVER_PROTOCOL    HTTP/1.1    

GATEWAY_INTERFACE    CGI/1.1    

REDIRECT_QUERY_STRING    /index/index    

REDIRECT_URL    /index/index    

REMOTE_PORT    50480    

SCRIPT_FILENAME    D:/myphp_www/PHPTutorial/WWW/tp6/public/index.php    

SERVER_ADMIN    admin@php.cn    

CONTEXT_DOCUMENT_ROOT    D:/myphp_www/PHPTutorial/WWW/tp6/public    

CONTEXT_PREFIX    

REQUEST_SCHEME    http    

DOCUMENT_ROOT    D:/myphp_www/PHPTutorial/WWW/tp6/public    

REMOTE_ADDR    127.0.0.1    

SERVER_PORT    80    

SERVER_ADDR    127.0.0.1    

SERVER_NAME    tp6.io    

SERVER_SOFTWARE    Apache/2.4.23 (Win32) OpenSSL/1.0.2j mod_fcgid/2.3.9    

SERVER_SIGNATURE    

SystemRoot    C:\WINDOWS    

HTTP_COOKIE    PHPSESSID=a334386e8fff32d2936329a874461407; pgv_pvi=4820957184; pgv_si=s5068664832; thinkphp_show_page_trace=0|0    

HTTP_ACCEPT_LANGUAGE    zh-CN,zh;q=0.9    

HTTP_ACCEPT_ENCODING    gzip, deflate    

HTTP_ACCEPT    text/html,application/xhtml xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8    

HTTP_USER_AGENT    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36    

HTTP_UPGRADE_INSECURE_REQUESTS    1    

HTTP_CACHE_CONTROL    max-age=0    

HTTP_CONNECTION    close    

HTTP_HOST    tp6.io    

REDIRECT_STATUS    200    

FCGI_ROLE    RESPONDER    

PHP_SELF    /index.php    

REQUEST_TIME_FLOAT    1558856696.332    

REQUEST_TIME    1558856696    

Environment Variablesempty

ThinkPHP Constantsempty

ThinkPHP V6.0.0RC1 { 十年磨一剑-为API开发设计的高性能框架 }


Fatal error: Uncaught Error: Call to a member function save() on null in D:\myphp_www\PHPTutorial\WWW\tp6\vendor\topthink\framework\src\think\Response.php:156 Stack trace: #0 D:\myphp_www\PHPTutorial\WWW\tp6\vendor\topthink\framework\src\think\initializer\Error.php(55): think\Response->send() #1 [internal function]: think\initializer\Error->appException(Object(Error)) #2 {main} thrown in D:\myphp_www\PHPTutorial\WWW\tp6\vendor\topthink\framework\src\think\Response.phpon line 156

Fatal error: Uncaught Error: Call to a member function save() on null in D:\myphp_www\PHPTutorial\WWW\tp6\vendor\topthink\framework\src\think\Response.php:156 Stack trace: #0 D:\myphp_www\PHPTutorial\WWW\tp6\vendor\topthink\framework\src\think\initializer\Error.php(55): think\Response->send() #1 D:\myphp_www\PHPTutorial\WWW\tp6\vendor\topthink\framework\src\think\initializer\Error.php(88): think\initializer\Error->appException(Object(think\exception\ErrorException)) #2 [internal function]: think\initializer\Error->appShutdown() #3 {main} thrown in D:\myphp_www\PHPTutorial\WWW\tp6\vendor\topthink\framework\src\think\Response.php on line 156


雨

reply all(2)
lk

dump(Db::query('SELECT * FROM `user`'));This is enough, the version in the tutorial is too old

YaoNanM

There are characters written incorrectly, please check the code carefully

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template