note 102440 added to errorfunc.configuration

[email protected] Mon, 14 Feb 2011 07:49:38 -0800
Newsgroups php.notes
Message-ID <[email protected]>
Note that if error_log is empty, errors/warnings/notices will be written to stderr (standard error stream), and this may be a problem if you is PHP in CLI.

<?php
# test.php
error_reporting(E_ALL);
ini_set('display_errors','On');

ini_set('error_log','my_file.log');
foreach(1 as $i);

ini_set('error_log','');
foreach(1 as $i);

ini_set('error_log','/dev/null'); #linux
foreach(1 as $i);
?>

php -f test.php
will output :
<?
Warning: Invalid argument supplied for foreach() in /test.php on line 7 # stdout
PHP Warning:  Invalid argument supplied for foreach() in /test.php on line 10 # stderr
Warning: Invalid argument supplied for foreach() in /test.php on line 10 # stdout
Warning: Invalid argument supplied for foreach() in /test.php on line 13 # stdout
?>

Errors displayed in the stdout (standard output stream) car be catched with the output buffering functions (ob_start/ob_get_clean) while strerr cannot.
----
Server IP: 89.31.146.176
Probable Submitter: 82.227.124.74
----
Manual Page -- http://www.php.net/manual/en/errorfunc.configuration.php
Edit        -- https://master.php.net/note/edit/102440
Del: integrated  -- https://master.php.net/note/delete/102440/integrated
Del: useless     -- https://master.php.net/note/delete/102440/useless
Del: bad code    -- https://master.php.net/note/delete/102440/bad+code
Del: spam        -- https://master.php.net/note/delete/102440/spam
Del: non-english -- https://master.php.net/note/delete/102440/non-english
Del: in docs     -- https://master.php.net/note/delete/102440/in+docs
Del: other reasons-- https://master.php.net/note/delete/102440
Reject      -- https://master.php.net/note/reject/102440
Search      -- https://master.php.net/manage/user-notes.php