Login form



Operations with file content, file cursor, PART 3
SEEK_SET - Set position equal to offset  bytes.
SEEK_CUR - Set position to current location plus offset .
SEEK_END - Set position to end-of-file plus offset .

<?
$f = fopen ("f_1.txt","a+");

echo "pradzia ".ftell($f)." <br>";

fwrite( $f, "jonas simas robertas \n",30);

echo "po irasymo 'jonas simas robertas \n' ".ftell($f)." <br>";

rewind($f);

echo "po grazinimo ".ftell($f)." <br> Isvedimas:<pre>";

while ( ! feof ($f)){ $a =fgets ($f ,30); echo $a; }

echo "</pre><br>po atvaizdavimo ".ftell($f)." <br>";

fseek ($f,-10,SEEK_END);

echo "grazinom atgal 10 simboliu " . ftell($f) . " <br>";

fwrite( $f, " aaaa\n",30);

echo "po kito irasymo 'aaaa' " . ftell($f) . " <br>";

rewind($f);

echo "po grazinimo ".ftell($f)." <br> isvedimas: <pre>";

while ( ! feof ($f)){ $a =fgets ($f ,30); echo $a; }

echo "</pre>po kito isvedimo ".ftell($f)." <br>";

fclose ($f);
?>

 
[ BBC news ][ Yahoo news ][ Linux guru ][ Webmaster ACE ]