PHP/File Directory/fgetc — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 10:04, 26 мая 2010

fgetc() function returns one character from the file or returns false on reaching the end of file.

   <source lang="html4strict">

Its syntax is: string fgetc (int filepointer) <? $fh = fopen("data.txt", "r"); while (! feof($fh)) :

    $char = fgetc($fh);
    print $char;

endwhile; fclose($fh); ?>

 </source>
   
  


Reading Characters with fgetc()

   <source lang="html4strict">

<html> <head> <title>Reading Characters with fgetc()</title> </head> <body>

<?php

   $filename = "test.txt";
   $fp = fopen( $filename, "r" ) or die("Couldn"t open $filename");
   while ( ! feof( $fp ) ) {
    $char = fgetc( $fp );
    print "$char
"; }

?>

</body> </html>

 </source>