php Laravel 5:解析错误:语法错误,意外的“?”,期望变量(T_VARIABLE)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48787078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5 : Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)
提问by TrueCode
On my Local server everything was good was using mailtrap mail server as smtp server. but when my website is on live server and when I trying to reset password (forgot password ) getting following error screenshot is attached.I am using hostgators cpanels inbuilt smtp.
any more details I will provide if needed.
在我的本地服务器上,使用 mailtrap 邮件服务器作为 smtp 服务器一切都很好。但是当我的网站在实时服务器上并且当我尝试重置密码(忘记密码)时,附加了以下错误屏幕截图。我正在使用内置 smtp 的 hostgators cpanels。如果需要,我会提供更多细节。
回答by Alexey Mezenin
You need to install PHP version 7.1 because nullable types were introduced in 7.1:
您需要安装 PHP 7.1 版,因为 7.1中引入了可空类型:
?string $value
And from the Laravel docs:
来自Laravel 文档:
You will need to make sure your server meets the following requirements:
PHP >= 7.1.3
您需要确保您的服务器满足以下要求:
PHP >= 7.1.3
回答by mutiemule
For php7.0 only
仅适用于 php7.0
If your server doesn't have php 7.1 and above and you are only restricted to use php7.0 do as below:
如果您的服务器没有 php 7.1 及更高版本,并且您只能使用 php7.0,请执行以下操作:
- Delete vendor folder
- Delete composer.lock file
Add this to composer.json file under
config
"platform": { "php": "7.0.0" }
- 删除供应商文件夹
- 删除 composer.lock 文件
将此添加到 composer.json 文件下
config
"platform": { "php": "7.0.0" }
As well, ensure PHP version under require
is set to 7.0.0 as shown below in config.platform.php
:
同样,确保下面的 PHP 版本require
设置为 7.0.0,如下所示config.platform.php
:
"config": {
"platform": {
"php": "7.0.0"
}
}
- Run composer install using CMD
- 使用 CMD 运行 composer install
This now will make sure that only dependencies compatible with php7.0 are installed.
现在这将确保只安装与 php7.0 兼容的依赖项。