PHP 7 - 不支持声明“strict_types”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35746444/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:33:47  来源:igfitidea点击:

PHP 7 - Unsupported declare 'strict_types'

phpapachetype-hinting

提问by nSams Dev

Im using PHP 7 for a small project, also using same configs in my local and production server. all works on my local server but on production server after doing the set up for LAMP i was unable to find the apache folder under /etc/php/7.0/apache, so what i was getting an internal server error so i added the in apache.conf

我在一个小项目中使用 PHP 7,也在我的本地和生产服务器中使用相同的配置。一切都在我的本地服务器上运行,但在为 LAMP 设置后在生产服务器上我无法在 /etc/php/7.0/apache 下找到 apache 文件夹,所以我遇到了内部服务器错误,所以我在 apache 中添加了.conf

<VirtualHost 127.0.0.1:80>
PHPINIDir /path/to/new/php_ini
</VirtualHost>

Then the internal server error disappeared and now im getting this:

然后内部服务器错误消失了,现在我得到了这个:

Warning: Unsupported declare 'strict_types' in /var/www/html/index.php on line 2

Any idea why!! Thanks in advance

知道为什么!!提前致谢

回答by Razor Mureithi

in laravel 5.8 i install PHP version 7.2 and worked

在 Laravel 5.8 中,我安装了 PHP 7.2 版并工作

回答by nSams Dev

I was trying to use Composer whilst figuring out this error: Composer showed that I needed ext-mbstring. I then ran:

我正在尝试使用 Composer,同时找出此错误:Composer 显示我需要 ext-mbstring。然后我跑了:

sudo apt-get install php7.0-mbstring

须藤 apt-get 安装 php7.0-mbstring

And everything worked, even the main error

一切正常,即使是主要错误

"Warning: Unsupported declare 'strict_types' in /var/www/html/index.php on line 2
"

was gone.

失去了。

Therefore I can only assume that missing extensions cause other unexpected errors.

因此我只能假设缺少扩展会导致其他意外错误。