I'm having trouble with the passthru() function when redirecting stderr to stdout

62 views Asked by At

Could you help me with this strange passthru() behavior?

This code writes the "Division by zero" error to test.log:

passthru('php -r "echo 1/0;" 2>logs/test.log >> logs/test.log');

But this code doesn't. It writes the error to console:

passthru('php -r "echo 1/0;" 2>&1 >> logs/test.log');

I was expecting that the stderr is redirected also to stdout. Is this a known issue with passthru?

I'm running this in a CLI script.

0

There are 0 answers