Skip to content
Advertisement

die() is not stopping code from executing

the problem is in the following:

echo 'Hello...';

die('I died...');

echo 'HAHAHA!!!';

on the web browser it is executing the echo after the die(). on the CLI stops on the die() and does not shows the echo as expected.

My Specs: PHP 7.4 (FPM) web server Nginx (also tried with apache with the same result)

Also I had a time long a test server on windows and it was exiting the script when exit or die was called, but somehow on the debian test server is not doing that.

is there something I am missing? do you guys have any tip?

Thanks in advance….

Update on 2022-07-27 :

script: enter image description here

Browser output: enter image description here

CLI output enter image description here

I’ve updated the PHP version (same happening): enter image description here

@MarkusZeller yes is disabled the opcache: enter image description here

still not working… but somehow on the windows server under php7.4.26 runs the script with the expected die

The development environment is windows with Debian 11 (WSL2) I have also tried it yesterday on a test machine I have in my home with base Debian 11 installed and it has the same issue. Same thing with the Debian 11 test server at work.

@YourCommonSense the script is the same. Here is the nginx path config: enter image description here

Advertisement

Answer

Solution:

The cause of the problem was on the extension php-uopz. After installing every extension individually and testing after every install, the behavior only happens after this extension is activated. Hope this helps in case anyone runs into the same issue.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement