Bug #63701 [Com]: Php CLI does not respect display_errors option to report to STDOUT.
| From: | ksours at internetbrands dot com | Date: | Mon, 19 Mar 2018 16:06:17 +0000 |
| Subject: | Bug #63701 [Com]: Php CLI does not respect display_errors option to report to STDOUT. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214408@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63701&edit=1
ID: 63701
Comment by: ksours at internetbrands dot com
Reported by: ksours at internetbrands dot com
Summary: Php CLI does not respect display_errors option to
report to STDOUT.
Status: Feedback
Type: Bug
Package: PHP options/info functions
Operating System: CentOS
PHP Version: 5.3.19
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
I don't remember the context for this report, so if you can't reproduce just close it.
Previous Comments:
------------------------------------------------------------------------
[2018-03-17 15:39:37] cmb@php.net
I cannot reproduce the described behavior on a recent PHP-7.1
checkout (the oldest version that could be target of a normal bug
fix).
So please try with a still supported version of PHP to verify
whether this issue has been resolved in the meantime.
------------------------------------------------------------------------
[2012-12-05 21:56:03] ksours at internetbrands dot com
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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63701&edit=1