Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Miscellaneous Functions : connection_aborted

connection_aborted

Check whether client disconnected (PHP 4, PHP 5)
int connection_aborted ( )

Checks whether the client disconnected.

Return Values

Returns 1 if client disconnected, 0 otherwise.

See Also
connection_status()
ignore_user_abort()
Connection Handling for a complete description of connection handling in PHP.

Code Examples / Notes » connection_aborted

rickyale

I know why nobody can use the functions connection_XXX(). If the php code do not send anything to buffer, the php dont check the connection, so, the connection_timeout will still NORMAL and will not be ABORTED.
Ex
<?php
Set_Time_Limit(0);  //this you know what gonna do
Ignore_User_Abort(True); //this will force the script running at the end
While(!Connection_Aborted()) {
  Echo "\n"; //this will save de while
  Flush(); //Now php will check de connection
   While(CONDITION) {
       Echo "My chat....";
   }
Sleep(1);
}
?>
end


phpcoder

Although the documentation indicates it returns an int, I found comparing the return value with numeric values does not seem to work.
Example (does not work):
<?php
if (connection_aborted()==1) {
fwrite($filehandle, 'aborted!');
}
?>
You're better off just assuming it returns boolean
Example (does work):
<?php
if (connection_aborted()) {
fwrite($filehandle, 'aborted!');
}
?>


Change Language


Follow Navioo On Twitter
connection_aborted
connection_status
connection_timeout
constant
define
defined
die
eval
exit
get_browser
__halt_compiler
highlight_file
highlight_string
ignore_user_abort
pack
php_check_syntax
php_strip_whitespace
show_source
sleep
sys_getloadavg
time_nanosleep
time_sleep_until
uniqid
unpack
usleep
eXTReMe Tracker