Note: The archives category content is an automatically generated focus channel and does not neccessarily reflect the opinions of this blog. No responsibility is taken for the external links presented here, follow at your own discretion.
The archives content is never scraped from sites - but an abstract obtained from search engines.
| Problem |
Solution |
Example |
Reference |
Recommended |
Simple demo on opening and reading contents of files in PHP. Script under example tab takes filename as a parameter, then opens it read-only and reads contents in data variable. Then it echoes a header and footer line, with the data in the middle.
|
|
| Problem |
Solution |
Example |
Reference |
Recommended |
<?php $filename=$argv[1]; $FH=fopen("$filename","r") or die("could not open $filename\n"); while(!feof($FH)) { $data.=fgets($FH); } fclose($FH); echo "###### beginning of $filename ######\n"; echo "$data"; echo "\n###### end of $filename ######\n"; exit(0); ?> Here is a run through: $ php -q readfiles.php rhyme.txt ###### beginning of rhyme.txt ###### Mary had a little lamb, It was always bleating. ###### end of rhyme.txt ######
|
Leave a Reply
You must be logged in to post a comment.