skip to main
|
skip to sidebar
Php Consultant
bidvertiser
internet advertising
Friday, September 12, 2008
Example 4 file reading
Examples:
$line = fgets($fh); //read a complete line from file.
echo $line; //render that line as HTML text
fclose($fh);
?>
$fh = fopen("myfile1.txt", "r");
$str = fgets($fh, 64); //read only 64 characters from the file
echo $str; //render 64 characters as HTML
$line2 = fgets($fh, 64); //read next 64 characters from the file
echo $str;
fclose($fh);
?>
Reading line by line:
$fh = fopen("myfile1.txt", "r");
while (!feof($fh))
{
$line = fgets($fh);
echo $line;
}
fclose($fh);
?>
Reading all lines at once: [Using function file_get_contents()]
$fh = fopen("myfile1.txt", "r");
$file = file_get_contents("myfile1.txt");
echo $file;
?>
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Forex
Blog Archive
►
2009
(2)
►
February
(1)
►
January
(1)
▼
2008
(35)
►
October
(14)
▼
September
(21)
Example 4 file reading
PHP file reading
Example open for read
PHP file open for read
Example code 4 create & open
PHP file create and open
Other functions
Session Name & ID
Session Start
PHP Session Functions Reference
What is a PHP Session?
PHP Form handling – POST Method
PHP Form handling – GET Method
The ‘include’ and ‘require’ functions Example
The ‘include’ and ‘require’ functions
DATE & TIME Formats
SAMPLE CODES
PHP Contents (Continued)
PHP Contents (Continued)
PHP Contents (Continued)
PHP Contents
Feedjit Live Blog Stats
page-rank10.com - PageRank10 Experiment
page-rank10.com
- PageRank10 Experiment
Partner links
Super Cars
Wresrtling
frontpage hit counter
No comments:
Post a Comment