鍍金池/ 問答/PHP/ ThinkPHP V5.1.18 部署到服務器上就報錯,本地正常

ThinkPHP V5.1.18 部署到服務器上就報錯,本地正常

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

http://abc.com/public/index.php
為什么在服務器上訪問時報如下錯誤,在本地電腦都能正常訪問

[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

回答
編輯回答
葬愛

clipboard.png

PHP 5.6 不支持??
PHP7.0 才新增的??語法

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

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

升級服務器php版本

2018年4月17日 22:11