An error was reported when ThinkPHP V5.1.18 was deployed to the server. It is normal locally.

I am using ThinkPHP V5.1.18
php on the server is PHP 5.6.36 (cli)

Why does http://abc.com/public/index.php
access the Times on the server with the following error: it can be accessed normally on the local computer

[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

Mar.25,2021

clipboard.png

PHP 5.6is not supported?
PHP7.0 is new. Syntax

For more information, please take a look at my article: PHP version Features


upgrade server php version

Menu