skip to main
|
skip to sidebar
Php Consultant
bidvertiser
internet advertising
Friday, September 12, 2008
Example 4 file reading
<br />Examples:<br /><?php $fh = fopen("myfile1.txt", "r"); <br /> $line = fgets($fh); //read a complete line from file.<br /> echo $line; //render that line as HTML text<br /> fclose($fh); <br />?> <br /><br /><?php <br /> $fh = fopen("myfile1.txt", "r"); <br /> $str = fgets($fh, 64); //read only 64 characters from the file<br /> echo $str; //render 64 characters as HTML<br /> $line2 = fgets($fh, 64); //read next 64 characters from the file<br /> echo $str; <br /> fclose($fh); <br />?> <br />Reading line by line:<br /><?php <br /> $fh = fopen("myfile1.txt", "r"); <br /> while (!feof($fh)) <br /> { <br /> $line = fgets($fh); <br /> echo $line; <br /> } <br /> fclose($fh); <br />?> <br />Reading all lines at once: [Using function file_get_contents()]<br /><?php <br /> $fh = fopen("myfile1.txt", "r"); <br /> $file = file_get_contents("myfile1.txt"); <br /> echo $file; <br />?> <br /><br />
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