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.file-get-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:[EMAIL PROTECTED] 
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to