Unix and Linux Discussions Tagged with he i |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
0 |
2,235 |
What is on Your Mind? |
|
|
|
8 |
2,518 |
UNIX for Dummies Questions & Answers |
|
|
|
0 |
2,097 |
IT Security RSS |
|
|
|
1 |
2,432 |
UNIX for Dummies Questions & Answers |
|
|
|
0 |
4,970 |
OS X Support RSS |
|
|
|
0 |
3,453 |
OS X Support RSS |
|
|
|
0 |
3,160 |
OS X Support RSS |
|
|
|
0 |
1,547 |
Complex Event Processing RSS News |
|
|
|
0 |
2,409 |
OS X Support RSS |
|
|
|
0 |
1,501 |
Complex Event Processing RSS News |
|
|
|
0 |
1,785 |
IT Security RSS |
|
|
|
0 |
3,450 |
UNIX and Linux RSS News |
|
|
|
8 |
5,001 |
UNIX for Dummies Questions & Answers |
|
|
|
8 |
6,320 |
UNIX for Dummies Questions & Answers |
|
|
|
6 |
4,940 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,112 |
Programming |
|
|
|
1 |
4,655 |
Programming |
|
|
|
1 |
4,574 |
Shell Programming and Scripting |
|
|
|
2 |
5,167 |
Shell Programming and Scripting |
|
|
|
2 |
3,132 |
UNIX for Advanced & Expert Users |
|
|
|
9 |
8,177 |
Programming |
|
|
|
1 |
5,003 |
Shell Programming and Scripting |
|
|
|
3 |
3,680 |
UNIX for Advanced & Expert Users |
|
|
|
4 |
3,263 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
3,015 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
2,707 |
UNIX for Dummies Questions & Answers |
|
|
|
13 |
8,247 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
3,851 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
6,023 |
IP Networking |
|
|
|
7 |
5,102 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,720 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
8,439 |
Programming |
|
|
|
1 |
4,315 |
UNIX for Advanced & Expert Users |
|
|
|
1 |
3,844 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
2,025 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
3,894 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
5,058 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
4,059 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
125,542 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
4,710 |
UNIX for Dummies Questions & Answers |
FEOF(3) 1 FEOF(3)
feof - Tests for end-of-file on a file pointer
SYNOPSIS
bool feof (resource $handle)
DESCRIPTION
Tests for end-of-file on a file pointer.
PARAMETERS
o $handle
-The file pointer must be valid, and must point to a file successfully opened by fopen(3) or fsockopen(3) (and not yet closed by
fclose(3)).
RETURN VALUES
Returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout); otherwise returns FALSE.
NOTES
Warning
If a connection opened by fsockopen(3) wasn't closed by the server, feof(3) will hang. To workaround this, see below example:
Example #1
Handling timeouts with feof(3)
<?php
function safe_feof($fp, &$start = NULL) {
$start = microtime(true);
return feof($fp);
}
/* Assuming $fp is previously opened by fsockopen() */
$start = NULL;
$timeout = ini_get('default_socket_timeout');
while(!safe_feof($fp, $start) && (microtime(true) - $start) < $timeout)
{
/* Handle */
}
?>
Warning
If the passed file pointer is not valid you may get an infinite loop, because feof(3) fails to return TRUE.
Example #2
feof(3) example with an invalid file pointer
<?php
// if file can not be read or doesn't exist fopen function returns FALSE
$file = @fopen("no_such_file", "r");
// FALSE from fopen will issue warning and result in infinite loop here
while (!feof($file)) {
}
fclose($file);
?>
PHP Documentation Group FEOF(3)