|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-03-17 15:39 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: cmb
[2018-03-17 15:39 UTC] cmb@php.net
[2018-03-19 16:06 UTC] ksours at internetbrands dot com
[2018-03-19 16:51 UTC] cmb@php.net
-Status: Feedback
+Status: Closed
[2018-03-19 16:51 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 05:00:01 2025 UTC |
Description: ------------ Run the script from the command line using something like: # php test.php > outstd.txt Note that I get the same behavior setting the display_errors in the php.ini instead of by the script. The problem only occurs in the CLI and only on Unix, Windows is fine. The use case here is that I would like to be able to test the eval, capture any errors, and report them via the app. Having it randomly output stuff to the stream messes up the reporting. There does not appear to be anyway to catch the output of STDERR with php using output buffering. Test script: --------------- <?php ini_set('display_errors', 'STDOUT'); include('foo'); ob_start(); eval ('foo alkadsjfladsjfladsfjl'); $foo = ob_get_contents(); ob_end_clean(); var_dump('xxx', $foo, 'xxx'); ?> Expected result: ---------------- PHP Warning: include(foo): failed to open stream: No such file or directory in /home/ksours/test.php on line 4 PHP Warning: include(): Failed opening 'foo' for inclusion (include_path='.:/php/includes:/usr/share/pear') in /home/ksours/test.php on line 4 PHP Parse error: syntax error, unexpected T_STRING in /home/ksours/test.php(6) : eval()'d code on line 1 the outstd.txt will contain: Warning: include(foo): failed to open stream: No such file or directory in /home/ksours/test.php on line 4 Warning: include(): Failed opening 'foo' for inclusion (include_path='.:/php/includes:/usr/share/pear') in /home/ksours/test.php on line 4 string(3) "xxx" string(102) " Parse error: syntax error, unexpected T_STRING in /home/ksours/test.php(6) : eval()'d code on line 1 " string(3) "xxx" Actual result: -------------- No output to STDERR when display_errors is set to STDOUT. It's also odd that the output buffering captures the output, but its still displayed.