Forum Moderators: coopster

Message Too Old, No Replies

Header ("Connection: close")

or exit;

         

dcrombie

2:46 pm on Apr 8, 2004 (gmt 0)



Relating to a post in this thread [webmasterworld.com], does anyone know if there is there any practical different between:

<?PHP 
Header("Location: [example.com...]
Header("Connection: close");
?>

and:

<?PHP 
Header("Location: [example.com...]
exit;
?>

?

From a (very) quick browse it seems that the exit [php.net] command will generate a "Connection: close" header by default. Does "Connection: close" have the same effect as exit in that no further PHP code on the page will be parsed?

encyclo

3:11 pm on Apr 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ermm, that was in my reply, and I'm far from being a PHP guru.

However, I know that you must have a Connection: close after using header to avoid problems with IE, but if "exit" sends a Connection: close, then I assume that would be fine too!

coopster

3:57 pm on Apr 8, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



exit() terminates the script and causes any responses to be sent to the browser.

Connection: close
is not necessarily IE-related, nor PHP related. It has to do with the HTTP protocol, specifically the differences between HTTP 1.0/HTTP 1.1 and persistent connections. RFC2616 [ietf.org], sections 14.10 and 8.1.