J'ai un problème étrange avec la sortie d'erreur sur le serveur intégré de PHP, et cela ressemble vraiment à un bug, mais je ne suis pas sûr à 100%.Serveur local PHP - double erreurs - bug ou non?
script Exemple:
<?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);
Si vous exécutez ce code dans la console (php example.php
), vous obtenez ce qui suit, prévu, sortie:
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
Cependant, si vous exécutez ce script une page Web (php -S localhost:9000 example.php
), et ouvrez l'URL, vous obtenez la sortie suivante dans la 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
La chose la plus étrange est que si vous ajoutez trigger_error('my error', E_USER_ERROR);
au bas de l'exemple de script, la sortie double est fixe.
Qu'est-ce qui cause cela? Est-ce un bug ou un peu bizarre avec les configs INI?
Avant tout, assurez-vous qu'il n'y a qu'une seule requête HTTP. La sortie que vous avez publiée est normale pour deux demandes. – axiac
L'avez vous essayé vous-même? – jurchiks
Dunno si cela rétrécit, mais je ne pouvais pas répliquer cela sur ma machine Linux. –