Req #72572 [Opn]: Error Reporting on Text-based Web Server
| From: | cmb@php.net | Date: | Mon, 11 Jul 2016 01:15:00 +0000 |
| Subject: | Req #72572 [Opn]: Error Reporting on Text-based Web Server | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202180@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72572&edit=1
ID: 72572
Updated by: cmb@php.net
Reported by: David at Refoua dot me
Summary: Error Reporting on Text-based Web Server
Status: Open
Type: Feature/Change Request
Package: Unknown/Other Function
Operating System: Any
PHP Version: 7.0.8
Block user comment: N
Private report: N
New Comment:
Good idea, but I'm afraid that is not generally possible. Consider
<?php
ob_start();
trigger_error(â¦);
header('Content-Type: â¦);
echo ob_get_clean();
Previous Comments:
------------------------------------------------------------------------
[2016-07-10 20:47:49] David at Refoua dot me
Description:
------------
When PHP is used with internal error reporting mechanism, PHP will determine if the error message is
printed on a command-line interface, or a Web Server (i.e. cgi). All CLI messages are outputted
using the text-only format.
However, this only is desired if the Web Server is only returning a HTML file. PHP should determine
the current header, and if Content-Type is set to text/plain, or text/*, or anything that a current
modern browser would not interpret as a HTML document, any content produced by HTML should be
formatted for a text-only output.
Therefore, PHP's own error reporting should output the same way CLI does, when the
header's Content-Type is set to text/plain with PHP.
Test script:
---------------
NOTE: This script is called with cgi from a web server, and not from cli.
<?php
header("Content-Type: text/plain");
abcd(); // An undefined function to produce error
?>
Expected result:
----------------
Fatal error: Uncaught Error: Call to undefined function abcd() in -:1
Stack trace:
#0 {main}
thrown in - on line 1
Actual result:
--------------
<br />
<b>Fatal error</b>: Uncaught Error: Call to undefined function abcd() in -:1
Stack trace:
#0 {main}
thrown in <b>-</b> on line <b>1</b><br />
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72572&edit=1