Portrety Uliczne Nieznajomych - zobacz wyjątkową galerię portretów z warszawskich ulic
ZALOGUJ SIĘ
login:
hasło:
przypomnij hasło
załóż konto użytkownika
(i zobacz kilka porad gratis)
   
WYSZUKIWARKA I DZIAŁY
całe porady  tytuły
zaznacz działy do przeszukania
(brak wyboru = wszystkie działy)
PHP
MySQL >
PostgreSQL
SQLite
Perl
Java
XML
XSLT
XPath
WML
SVG
RegExp
Wyszukiwarki
Ochrona
VBScript
Google Plus
XHTML/CSS
JavaScript
Grafika
Flash
Photoshop
Windows
Linux
Bash
Apache
Procmail
E-biznes
Explorer
Opera
Firefox
Inne porady
   
KURSY, DOKUMENTACJE
Własne:
XHTML/CSS
JavaScript
ActionScript
WML, RSS, SSI
Pozostałe:
PHP
MySQL
Java API
więcej...
   
użytkowników online: 63
W CZYM MOGĘ POMÓC?


   
OPINIE UŻYTKOWNIKÓW
O wysokich kompetencjach zawodowych Darka nie ma co dyskutować. Wszyscy chyba jesteśmy zgodni co do tego, że Jego wiedza na polu informatycznym jest bogata i zasługuje na uznanie. Swego czasu zwróciłem się z prośbą o pomoc w realizacji małego projektu internetowego. Projekt był niewielki, jednak jego realizacja wymagała pewnego doświadczenia. Darek podjął się tego zlecenia, wykonał je szybko i sprawnie. Podczas realizacji służył doradztwem, jednak w żaden sposób nie narzucał swojego zdania. O prawidłowości Jego koncepcji przekonałem się dopiero po pewnym czasie. To, czego ja nie dostrzegałem, On dostrzegał i zwracał na to moją uwagę. Darek dał się poznać nie tylko, jako dobry fachowiec, co przede wszystkim okazał się być rzetelnym i uczciwym kontrahentem. Tak więc nie dość, że fachowiec, to jeszcze uczciwy. Polecam usługi Darka wszystkim tym, którzy szukają fachowej pomocy przy realizacji nawet najbardziej złożonych projektów.

Dariusz Żwan
Actuarius.pl

   
GALERIA FOTOGRAFII
   
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net

[Spis] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [X] [W] [Z]

feof

(PHP 3, PHP 4, PHP 5)

feof -- Sprawdza czy wskaźnik pliku jest na końcu pliku (EOF)

Opis

bool feof ( resource uchwyt )

Zwraca TRUE jeśli wskaźnik pliku jest na EOF lub gdy zdarzy się błąd (także timeout połączena socket'owego);w przeciwnym wypadku zwraca FALSE.

Ostrzeżenie

Jeśli połączenie otworzone za pomocą fsockopen() nie zostanie zamknięte przez serwer, feof() będzie czekać aż timeout zostanie osiągniety, wtedy zwróci TRUE. Domyślny timeout to 60 sekund. Możesz użyć stream_set_timeout() aby zmienić tą wartość.

Wskaźnik na plik musi być poprawny i musi wskazywać na plik pomyślnie otwarty przez funkcję fopen() lub fsockopen().




User Contributed Notes

docey
12-Jan-2006 08:07

because using an invalid handle can couse seriuos trouble,
here is some very simple code that can prevent any piece
of code to runaway using an invalid handle.

function is_valid(&$fp, $type){
 if(is_resource($fp)){
   if(get_resource_type($fp) == $type){
   return true;
   }else{
   return false;
   }
 }else{
  return false;
 }
}

now all you need to do to check if you got a valid handle,

if(is_valid($fp, "file")){
 // your code
}else{
 // your error code
}

its that simple to prevent any of your code from using an
invalid handle. ofcourse you can change the "file" line to
any resource you want to check for invalidies.

please use good coding habits, and don't assume any
varialbles, resource or objects are good. check them!!


02-Jan-2006 03:27

if you use fseek function to pos the pointer exceed the size the file,feof still return true.so note that when you use feof as the condition of while loop.


info at derlange dot tk
06-Aug-2005 12:20

NOTE!
if your file is empty and you make the feof()-check, it will return true the first time you call it.
example:
$handle=fopen("file","r");
while(!feof($handle))
{
 $line=fgets($handle);
}
$line is now an empty string ( "" )

you have to check the size of your file before, like this sample code:
if (filesize("file")>0)
{
 while( !feof($handle) )
 {
  $zeile=fgets($handle);
 }
}


01-Aug-2005 07:21

if you hit an feof() infinite loop, watch out for resultant humongous logs, they can cripple a site with hard disk usage limits or run up excess usage fees.


04-Mar-2005 06:02

if you're worried the file pointer is invalid, TEST IT before you go into your loop... that way it'll never be an infinite loop.


bruno dot moreira at brturbo dot com
13-Jan-2005 12:43

Use it with many caution. If your php.ini don't stop the script when it enter a infinity loop.
I don't think as good the use of feof with an while loop.
See the example:
$a=open("/etc/passwd");
while(!feof($a)){
 echo fgets($a);
 }
I used '/etc/passwd' because obviously the apache user isn't root, then cannot read '/etc/passwd'.
If in future the feof return's some different that TRUE or FALSE, this can be used with good results.


mark at newfangled dot com
04-May-2004 07:39

When a fopen() is done on a file that has permissions that are set to
not allow the current process user to read it or the file doesn't exist
it returns false. This is expected. The problem is when feof() is fed
the invalid handle it doesn't return TRUE() thus creating an infinite
loop in the following code example.

<?php
$fp
= fopen( 't.txt', 'r' );

while( !
feof( $fp ) )
{
   print
fgets( $fp );
}

fclose( $fp );
?>

feof() would return TRUE to cancel the loop and the script would end.
There would of course be warnings because of the invalid file handle,
but that is expected.

There should be better error handling on the developers part and catch
the invalid file handle, but I would expect the file functions to handle
this situation accordingly.


Johannes
12-Mar-2004 11:47

I found feof() to be a slow function when using a non-blocking connection.

The function stream_get_meta_data() returns much quicker and has a return field 'eof'.


 

 
  © 1996-2012 & Reporter.plmiejscao serwisieabonamentwarunki korzystaniaRSSkontakt