PHP的die()函数为什么失效?在我的电脑上,die()无效。

3

我是通过homebrew安装在MacOS上的PHP 8.1.10...

里面只有一个空白的index.php文件,里面仅包含以下代码...

<?php
die('We Should Just Die Here');

throw new \RuntimeException('This exception should never be seen');
?>

并在浏览器中渲染以查看...

<br />
<b>Fatal error</b>:  Uncaught RuntimeException: This exception should never be seen in /path/to/public/index.php:4
Stack trace:
#0 /Users/my-user/.composer/vendor/laravel/valet/server.php(234): require()
#1 {main}
  thrown in <b>/path/to/public/index.php</b> on line <b>4</b><br />

如果我在命令行中运行它(不考虑 valet),那么故事是一样的。

$ php index.php

Fatal error: Uncaught RuntimeException: This exception should never be seen in /path/to/public/index.php:4
Stack trace:
#0 {main}
  thrown in /path/to/public/index.php on line 4

我已经尝试过以下方法:

  • 升级PHP
  • 重新安装Valet
  • 使用Composer更新所有内容

在我大约800年写PHP代码的经验中,我从未见过这样的情况。如果有人能提供帮助,我很感兴趣。


这个问题/答案对任何人都没有帮助。文档中已经提到了效果,不需要在这里重复。投票关闭该问题。 - arkascha
1个回答

2

我找到了原因。之前我安装了php-uopz扩展,但是我完全忘记了这件事。

pecl uninstall uopz命令解决了我的问题。

感谢你们的帮助!


1
我只是想说一下 ;) 这在 PHP 文档中有提到,在公共评论中。 - Honk der Hase
1
很高兴你解决了它。我一直在尝试重新创建它,但显然没有成功。 - Adam
你为什么要安装 php-uopz - matiaslauriti
有一些使用 php-uopz 的情况..通常对我来说,这涉及到为单元测试模拟数据或功能。 - rtconner

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接