Go Back   TechArena Community > Software > Tips & Tweaks
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



PHP Headers already sent by

Tips & Tweaks


Reply
 
Thread Tools Search this Thread
  #1  
Old 19-12-2008
Member
 
Join Date: May 2008
Posts: 37
PHP Headers already sent by
  

When you use a PHP function that manipulates the headers such as http:
  • header ()
  • setcookie ()
  • session_start ()

It is important to use these functions before they generated any flows to the client. From the moment information was sent to the client (usually a top display a web page), it means that the HTTP headers have already been automatically sent to the client. This type of feed is frequently sent with the functions echo, print, etc..

If there is a free before the opening of the first php tag, then this space could be sent as the top web client and therefore http headers in the preceding automatically mean the client what type of feed it question. Here is an example of a head with the homepage CCM:

Server: Apache
X-Powered-By: Php/4.4.0-0.dotdeb.0
Keep-Alive: timeout = 15, max = 50
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-type: text / html; charset = iso-8859-1

So it is important to understand the system:
  • I echo or print at the beginning of my script. Ditto, if I have a space in my script that is not included in my php tags, it will be considered as part of the source of the page to send and headers precede. This may cause an error of the kind which seeks the solution for several days :-)
  • The server sends this data, and preceded by failure of headers which means that this is an html page.
  • If after this in my script I use a function key to the headers, it can no longer do so because the headers have already been sent. I get an error like "headers already sent".

Reply With Quote
Reply

  TechArena Community > Software > Tips & Tweaks
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "PHP Headers already sent by"
Thread Thread Starter Forum Replies Last Post
Regex for defining headers TechGate Software Development 5 16-02-2010 05:00 AM
HTTP headers Dharamsi Software Development 5 02-02-2010 06:23 PM
How to create headers in wordpad Jiten W Windows Software 3 17-08-2009 01:41 PM
Headers and Sources in C++ Hamir Software Development 3 19-02-2009 10:16 AM
Gmail won't download headers! rEDNESS Windows Vista Mail 3 27-05-2008 12:51 AM


All times are GMT +5.5. The time now is 11:48 PM.