PHP file handling
Posted: Tue Feb 17, 2009 10:14 am
Hi all,
I am absolutely a beginner to PHP and even to developing. i am learning php via. http://www.phphelps.com and at one stage i came across File handling in php. Below here is the example code given in the tutorial
When i run this code, i got into infinite loop and moreover i don't know where i have to store the file "data.txt" in my local hard drive. Even i tried with the full path to read this file but am getting error "No such file or directory exists". Presently i stored this file in the directory which is the web server's (Apache)\htdocs. can anyone please help with this? so that i can move further in my learning.
Thanks in Advance
I am absolutely a beginner to PHP and even to developing. i am learning php via. http://www.phphelps.com and at one stage i came across File handling in php. Below here is the example code given in the tutorial
Code: Select all
<?php
$file = "data.txt";
$fp = fopen($file, "r");
while(!feof($fp)) {
$data = fgets($fp, 1024);
echo "$data <br>";
}
fclose($fp);
?>
Thanks in Advance