简体   繁体   English

分析错误语法错误,意外? [php 7.1.3]

[英]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 您好,我知道这个问题已经得到了很多答案,但是如果我安装了较新版本的php,并且仍然出现此错误,则不会

Parse error: syntax error, unexpected "?" 解析错误:语法错误,意外的“?”

This error comes from my autoloader in symfony. 此错误来自我在symfony中的自动装带器。

My composer .json and .lock both say 7.1.3 我的作曲家.json和.lock都说7.1.3

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

I tried just getting the phpinfo..but for some reason that wont work either 我试着只是获取phpinfo ..但由于某种原因也无法正常工作

phpinfo();
die();

This wont return anything. 这不会返回任何东西。

Here is smyfonys index.php the error apears at the second and third if statment. 这是smyfonys index.php,如果出现第二个错误和第三个错误,则会出现错误。

<?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. 我发现的是,在装有xampp和7.3.1 Windows pc上,我的服务器工作正常。

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.... Om我的Mac用7.1.3 MAMP无法正常工作。这个想法是json和phpstorm都设置为7.1,所以这就是为什么我很困惑的原因。

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. 看起来带有7.1.3 MAMP实际上并没有运行7.1.3但是更低一些,不支持null coalesce运算符。 Perhaps you can output the version of php in your index.php using the phpversion() function. 也许您可以使用phpversion()函数在index.php输出php的版本。 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 使用Symfony时,使用其需求检查器检查系统是否正确设置也可能很有用: https : //symfony.com/doc/current/reference/requirements.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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