This is a discussion on File reading code2 within the PHP General forums, part of the PHP Programming Forums category; Hi, Can someone make me an example of simple reading a *.txt file on a hard drive and displaying that ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
Can someone make me an example of simple reading a *.txt file on a hard drive and displaying that file with a echo command or some loop or anything path to file: (C:\Program Files\XAMPP\xampp\htdocs\test_folder\test1.txt) btw the script is in this folder to. Full code please. Thanks in advance! |
|
|||
|
This just dumps the content to the browsers. You could use file() instead if
you want to loop thru every line. $file = "test1.txt"; if(file_exists($file)) { if(is_readable($file)) { if($file_content = get_file_contents($file)) { echo "<pre>"; echo $file_content; echo "</pre>"; } echo "Something went wrong"; } else echo "Cannot read the file '$file', check permissions"; } else echo "The file '$file' does not exist in this directory"; You should learn how to read the manual, because in the end we will not do this kind of things if it already is in the manual. http://th.php.net/manual/en/function...t-contents.php http://th.php.net/file Best regards, Peter Lauri www.dwsasia.com - company web site www.lauri.se - personal web site www.carbonfree.org.uk - become Carbon Free -----Original Message----- From: Delta Storm [mailto:delta.storm@hi.t-com.hr] Sent: Saturday, January 06, 2007 10:39 AM To: php-general@lists.php.net Subject: [php] File reading code2 Hi, Can someone make me an example of simple reading a *.txt file on a hard drive and displaying that file with a echo command or some loop or anything path to file: (C:\Program Files\XAMPP\xampp\htdocs\test_folder\test1.txt) btw the script is in this folder to. Full code please. Thanks in advance! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |