【问题标题】:PHP 7 - Unsupported declare 'strict_types'PHP 7 - 不支持声明“strict_types”
【发布时间】:2016-06-15 06:14:32
【问题描述】:

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

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

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

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

知道为什么!! 提前致谢

【问题讨论】:

  • php -v 在您的生产服务器中返回什么?
  • @apokryfos 这是我得到的 PHP 7.0.3-13+deb.sury.org~trusty+1 (cli) (NTS)
  • 在你的 apache http 根目录上创建一个简单的页面:

标签: php apache type-hinting


【解决方案1】:

我试图使用 Composer 来解决这个错误:Composer 显示我需要 ext-mbstring。然后我跑了:

sudo apt-get install php7.0-mbstring

一切正常,甚至主要错误也消失了:

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

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

【讨论】:

    【解决方案2】:

    在 laravel 5.8 中,我安装 PHP 7.2 版并正常工作

    【讨论】:

      【解决方案3】:

      我使用 cPanel 中的 MultiPHP Manager 工具将 PHP 从 7.4 降级到 7.3,它工作正常。

      【讨论】:

        猜你喜欢
        • 2021-02-02
        • 1970-01-01
        • 2018-05-16
        • 2015-10-08
        • 1970-01-01
        • 2023-03-22
        • 2020-07-15
        • 2017-12-10
        相关资源
        最近更新 更多