Warning for header information in my test server but not in local why?
I have my site live in which i echoed few strings for testing, so it displayed me those test strings but a开发者_JAVA技巧long with the warning message
Warning: Cannot modify header information - headers already sent by (output started at /home/companyfolder/public_html/mycart.php:117) in /home/companyfolder/public_html/includes/functions/general.php on line 50
But at the same time i do not get this error any where in my local machine so i want to know is there any difference in display of header information related to servers?
Because of output buffering
And not a single one, who volunteered to share their knowledge about error handling, mentioned a way more likely reason - display_errors turned off, as it on the live site ought to be.
Of course it should be. To
- not to scare users with strange messages
- not to reveal vital info of your application to possible attacker. nor to supply them with any feedback.
- inform a programmer of all errors occurred, by turning
log_errors
setting on
Thus, on a development site
display_errors = on
log_errors = off
on a live site
display_errors = off
log_errors = on
while error reporting level should remain the same - E_ALL or better
You have the same issue in both places, just different error reporting levels. You can configure this in your php.ini file or at runtime with error_reporting()
This error is pretty general, but basically what is happening is what it says. You're including mycart.php in a page and on like 117 it starts outputting HTML (or something client-side), once this starts happening you can't modify any of the header information (ex. a redirect). Like jason said though, the reason the error isn't showing up is the error_reporting setting.
EDIT: You can solve some of these problems by using ob_start() and then ob_end_flush() after you've done your header modifying.
Your other server configuration might have output buffering
turned on in the php.ini file.
The server has this in php.ini
error_reporting(E_ALL);
if you just want errors then use
error_reporting(E_ERROR | E_PARSE);
精彩评论