I'm having a weird problem with error output on PHP's built-in server, and it really looks like a bug, but I'm not 100% sure.
Example script:
<?php
error_reporting(-1);
ini_set('display_errors', '0');
ini_set('log_errors', '1');
ini_set('ignore_repeated_errors', true);
trigger_error('my notice', E_USER_NOTICE);
trigger_error('my warning', E_USER_WARNING);
If you execute this code in the console (php example.php), you get the following, expected, output:
PHP Notice: my notice in C:\php\example.php on line 7
PHP Stack trace:
PHP 1. {main}() C:\php\example.php:0
PHP 2. trigger_error('my notice', 1024) C:\php\example.php:7
PHP Warning: my warning in C:\php\example.php on line 8
PHP Stack trace:
PHP 1. {main}() C:\php\example.php:0
PHP 2. trigger_error('my warning', 512) C:\php\example.php:8
However, if you run this script as a webpage (php -S localhost:9000 example.php), and open the URL, you get the following output in the console:
PHP 7.1.10 Development Server started at Tue Oct 10 19:46:05 2017
Listening on http://localhost:9000
Document root is C:\php
Press Ctrl-C to quit.
[Tue Oct 10 19:46:06 2017] PHP Notice: my notice in C:\php\example.php on line 7
[Tue Oct 10 19:46:06 2017] PHP Stack trace:
[Tue Oct 10 19:46:06 2017] PHP 1. {main}() C:\php\example.php:0
[Tue Oct 10 19:46:06 2017] PHP 2. trigger_error('my notice', 1024) C:\php\example.php:7
[Tue Oct 10 19:46:06 2017] PHP Warning: my warning in C:\php\example.php on line 8
[Tue Oct 10 19:46:06 2017] PHP Stack trace:
[Tue Oct 10 19:46:06 2017] PHP 1. {main}() C:\php\example.php:0
[Tue Oct 10 19:46:06 2017] PHP 2. trigger_error('my warning', 512) C:\php\example.php:8
[Tue Oct 10 19:46:07 2017] PHP Notice: my notice in C:\php\example.php on line 7
[Tue Oct 10 19:46:07 2017] PHP Stack trace:
[Tue Oct 10 19:46:07 2017] PHP 1. {main}() C:\php\example.php:0
[Tue Oct 10 19:46:07 2017] PHP 2. trigger_error('my notice', 1024) C:\php\example.php:7
[Tue Oct 10 19:46:07 2017] PHP Warning: my warning in C:\php\example.php on line 8
[Tue Oct 10 19:46:07 2017] PHP Stack trace:
[Tue Oct 10 19:46:07 2017] PHP 1. {main}() C:\php\example.php:0
[Tue Oct 10 19:46:07 2017] PHP 2. trigger_error('my warning', 512) C:\php\example.php:8
The weirdest thing is that if you add trigger_error('my error', E_USER_ERROR); at the bottom of the example script, the double output is fixed.
What causes this? Is it a bug or some weirdness with the INI configs?