简体   繁体   中英

Parse error syntax error, unexpected ? [php 7.1.3]

Hello i know this problem has been answer a lot but not if i have the newer version of php and i still get this error

Parse error: syntax error, unexpected "?"

This error comes from my autoloader in symfony.

My composer .json and .lock both say 7.1.3

"require": {
        "php": "^7.1.3",`

I tried just getting the phpinfo..but for some reason that wont work either

phpinfo();
die();

This wont return anything.

Here is smyfonys index.php the error apears at the second and third if statment.

<?php

use App\Kernel;
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;

require dirname(__DIR__).'/config/bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
    umask(0000);

    Debug::enable();
}

if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}

if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
    Request::setTrustedHosts([$trustedHosts]);
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

What i discovered is, that on my windows pc with xampp and 7.3.1 my sever works no problem.

Om my mac with MAMP with 7.1.3 it does not work.. The idea is that both json and phpstorm are set to 7.1 So this is why i am very confused....

Any ideas ?

Thank you.

Looks like MAMP with 7.1.3 doesn't actually run 7.1.3 but something lower, that doesn't support the null coalesce operator. Perhaps you can output the version of php in your index.php using the phpversion() function. var_dump(phpversion())

When using Symfony, it might also be useful to check if your system is setup properly using their requirements checker: https://symfony.com/doc/current/reference/requirements.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM