【发布时间】:2018-12-07 12:42:26
【问题描述】:
我从周三开始就一直在解决这个问题,我在 PHP 5.6 和 PHP 7.2(也是 7.1)之间的研究和测试后的结果是:我的 PHP 7 没有抱怨或注意到我的环境中缺少扩展。
取而代之的是,它只是停止执行而没有错误消息。
问题
为什么 PHP 7.x 会在脚本中间停止执行*,并且不再因缺少 PHP 扩展而触发错误通知或提示?
* 主要在函数需要使用特定 PHP-Extension 的位置。
环境
Operating System : Debian GNU/Linux 9.6 (stretch)
Web Server : nginx/1.10.3
PHP : PHP 7.2.12
/etc/apt/sources.list
# deb cdrom:[Debian GNU/Linux 9.2.1 _Stretch_ - Official amd64 NETINST 20171013-13:07]/ stretch main
#deb cdrom:[Debian GNU/Linux 9.2.1 _Stretch_ - Official amd64 NETINST 20171013-13:07]/ stretch main
deb http://ftp.de.debian.org/debian/ stretch main
deb-src http://ftp.de.debian.org/debian/ stretch main
deb http://security.debian.org/debian-security stretch/updates main
deb-src http://security.debian.org/debian-security stretch/updates main
# stretch-updates, previously known as 'volatile'
deb http://ftp.de.debian.org/debian/ stretch-updates main
deb-src http://ftp.de.debian.org/debian/ stretch-updates main
问题
虽然 PHP 5.6 抱怨缺少驱动程序或无效函数,但它只是在我的代码中间必要时停止执行,而不会出现错误消息。
示例:如果其中一些扩展未安装,则会出现问题:
php7.2-mysql
php7.2-mbstring
php7.2-soap
php7.2-simplexml
这个问题真的很令人困惑,因为我在/etc/php/7.2/fpm/php.ini 中启用了错误报告和显示错误、启动错误,并且还使用...
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting( E_ALL | E_STRICT);
...在我的代码中。但是,仍然不会出现缺少扩展的消息或错误。
当函数调用缺少必要的扩展时,PHP 7.2 是否不再能够抛出错误?还是php.ini 的默认设置中存在一些错误配置?
我错过了什么?
20181210
解决方案
最后这是我自己的错,我让我的路由器脚本尝试/捕获异常和 Throwable 到一个变量中,但当时没有转储或调试它们。很抱歉打扰了
其他重要说明
为了确保我在这里的问题易于理解:对于大多数常见错误,例如函数拼写错误、语法错误、声明、要求、丢失文件,我可以获得错误通知和异常等等。但我在这里的问题是
PHP 7.2无法注意到缺少某些 php-extension,而是在页面或日志上提供一些反馈,它只是停在需要/应该需要 php-extension 的功能。
【问题讨论】:
标签: php nginx php-extension php-7.2