ID: 21046 User updated by: [EMAIL PROTECTED] -Summary: notice leaks output when display_errors is off Reported By: [EMAIL PROTECTED] -Status: Feedback +Status: Open Bug Type: Output Control Operating System: linux -PHP Version: 4.3.0RC3 +PHP Version: 4.3.0RC2 New Comment:
phpinfo() reports that display_errors is off. Running the script that [EMAIL PROTECTED] suggested produces the output: Could not set cookie, log errs on, display_errs Also, php is running as a cgi binary. Previous Comments: ------------------------------------------------------------------------ [2002-12-16 10:36:50] [EMAIL PROTECTED] Could you try this version instead, and report the output? <? error_reporting(E_ALL); if (!$undefinedVariable) { if (setcookie ("code","123456")) { print "Cookie set, "; } else { print "Could not set cookie, "; } } print (ini_get('log_errors')) ? 'log errs on, ' : 'log errs off'; print (ini_get('display_errors')) ? 'display errs on' : 'display_errs off'; ?> ------------------------------------------------------------------------ [2002-12-16 10:35:49] [EMAIL PROTECTED] In the same directory as your script put a script with <?php phpinfo(); ?> Then in the output of that script check what the display_errors is set to, it is possible that you are either using the wrong .ini file, httpd.conf overwriting your settings for the virtual host or you have .htaccess that changes display_errors to On. So far, neither I nor other developers who have tried to replicate the problem you've described were able to do so. ------------------------------------------------------------------------ [2002-12-16 10:05:59] [EMAIL PROTECTED] If a script generates a php notice (which is logged, not displayed to the screen) something gets output anyway; this output can prevent setting cookies. <? if (!$undefinedVariable) { if (setcookie ("code","123456")) { print "Cookie set"; } else { print "Could not set cookie"; } } ?> We get the following in the server log: PHP Notice: Undefined variable: undefinedVariable in /home/www/dev/pLogin.php on line 2 PHP Warning: Cannot modify header information - headers already sent in /home/www/dev/pLogin.php on line 3 However, if you add the line $undefinedVariable = false; so that the notice goes away, PHP will happily set the cookie. display_errors = off, error_reporting = E_ALL, log_errors = On. Note: This happens on 4.3.0RC2; unfortunately, I could not test on RC3. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21046&edit=1