note 75835 added to function.headers-sent

From: Date: Mon, 18 Jun 2007 09:32:27 +0000
Subject: note 75835 added to function.headers-sent
Groups: php.notes 
Request: Send a blank email to php-notes+get-127531@lists.php.net to get a copy of this message
In response to K.Tomono and alexrussell101 at gmail dot com : Yes, headers_sent() will return false, even if you sent something to the ouptut using print() or header() , if output_buffering is different from Off in you php.ini, and the length of what you sent does not exceed the size of output_buffering. To test it, try this code with these values in php.ini 1) output_buffering=32 2) output buffering = 4096 [code] <?php echo "Yo<br />"; echo "Sent:",headers_sent(),"<br />"; echo "enough text to feed the buffer until it overflows ;-)<br />"; echo "Sent:",headers_sent(),"<br />"; ?> [/code] then put 3) output buffering = Off and try this code [code] <?php echo "Yo<br />"; echo "Sent:",headers_sent(),"<br />"; ?> [/code] which will this time unconditionnally say that headers were sent. This is noticed in php.ini comment : "Output buffering allows you to send header lines (including cookies) even after you send body content, in the price of slowing PHP's output layer a bit." Note : This is completly independant of implicit_flush tuning. ---- Server IP: 217.174.196.197 Probable Submitter: 212.198.247.242 ---- Manual Page -- http://www.php.net/manual/en/function.headers-sent.php Edit -- https://master.php.net/note/edit/75835 Del: integrated -- https://master.php.net/note/delete/75835/integrated Del: useless -- https://master.php.net/note/delete/75835/useless Del: bad code -- https://master.php.net/note/delete/75835/bad+code Del: spam -- https://master.php.net/note/delete/75835/spam Del: non-english -- https://master.php.net/note/delete/75835/non-english Del: in docs -- https://master.php.net/note/delete/75835/in+docs Del: other reasons-- https://master.php.net/note/delete/75835 Reject -- https://master.php.net/note/reject/75835 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#127531) next »