鍍金池/ 問(wèn)答/PHP/ ThinkPHP V5.1.18 部署到服務(wù)器上就報(bào)錯(cuò),本地正常

ThinkPHP V5.1.18 部署到服務(wù)器上就報(bào)錯(cuò),本地正常

我使用的是ThinkPHP V5.1.18版本
服務(wù)器上php版本是PHP 5.6.36 (cli)

http://abc.com/public/index.php
為什么在服務(wù)器上訪問(wèn)時(shí)報(bào)如下錯(cuò)誤,在本地電腦都能正常訪問(wèn)

[4] ErrorException in Helpers.php line 83
syntax error, unexpected '?'
/**

  • Return current url.

*

  • @return string

*/
function current_url()
{

$protocol = 'http://';

if ((!empty($_SERVER['HTTPS']) && 'off' !== $_SERVER['HTTPS']) || ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? 'http') === 'https') {
    $protocol = 'https://';
}

return $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

}

/**

  • Return random string.

*
Call Stack
in Helpers.php line 83
at Error::appShutdown()
Environment Variables

回答
編輯回答
葬愛(ài)

clipboard.png

PHP 5.6 不支持??
PHP7.0 才新增的??語(yǔ)法

詳細(xì)可以看看我這篇文章:PHP 歷代版本特性

2017年7月16日 05:38
編輯回答
病癮

升級(jí)服務(wù)器php版本

2018年4月17日 22:11