php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63701 Php CLI does not respect display_errors option to report to STDOUT.
Submitted: 2012-12-05 21:56 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: ksours at internetbrands dot com Assigned:
Status: Open Package: PHP options/info functions
PHP Version: 5.3.19 OS: CentOS
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-12-05 21:56 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 10:02:06 2014 UTC