<?php
/*
*for reading only
* */
$pointer = fopen('php.txt', 'r'); //first argument is file name, 2nd parameter is mode some modes are r, w, a, a+
//fgets() return one line from file keep cursor to end of the line
echo fgets($pointer) ;
echo '<br>';
echo fgets($pointer) ;
echo '<br>';
fclose($pointer);
$pointer2 = fopen('php.txt', 'r');
//fgets() return one line from file keep cursor to end of the line
echo fgets($pointer2) ;
echo '<br>';
echo fread($pointer2, filesize('php.txt'));//this line echoing everything (all word) from php.txt
echo '<br>';
fclose($pointer2);
$pointer3 = fopen('php.txt', 'r');
while(!feof($pointer3)){
echo fgetc($pointer3) . '<br>';
}
fclose($pointer3);
//feof() is file-end-of-file, fgetc() is file-get-character();
/*
*for reading only
* */
$pointer = fopen('php.txt', 'r'); //first argument is file name, 2nd parameter is mode some modes are r, w, a, a+
//fgets() return one line from file keep cursor to end of the line
echo fgets($pointer) ;
echo '<br>';
echo fgets($pointer) ;
echo '<br>';
fclose($pointer);
$pointer2 = fopen('php.txt', 'r');
//fgets() return one line from file keep cursor to end of the line
echo fgets($pointer2) ;
echo '<br>';
echo fread($pointer2, filesize('php.txt'));//this line echoing everything (all word) from php.txt
echo '<br>';
fclose($pointer2);
$pointer3 = fopen('php.txt', 'r');
while(!feof($pointer3)){
echo fgetc($pointer3) . '<br>';
}
fclose($pointer3);
//feof() is file-end-of-file, fgetc() is file-get-character();
No comments:
Post a Comment