![]() |
|
|
+ Search |
![]()
|
Mar 7th, 2002 04:48
Paul Gault, Guest,
hope this helps, 3 seemed to work correctly
<?
/* the contents of the file to be read, users/rashid.txt, are
rashid,rere,as,as */
$fileText="rtrterte"; //give string any initial value
print("<p> 1. file contents are $fileText"); //show it
$fp=fopen("users/rashid.txt","r"); // open file for reading
$filename = "users/rashid.txt"; //string containing filename
if($fp){ //if file opened succesfully
$fileText=fread ($fp,filesize($fp)); //read file using filesize arg
as $fp
print("<p> 2. file contents are $fileText");
$fileText=fread ($fp,filesize($filename)); //read file using
filesize arg as $filename
print("<p> 3. file contents are $fileText");
$fileText=fread ($fp,1024); //read 1024 bytes
print("<p> 4. file contents are $fileText");
fclose($fp);
}
else{
print"<p>false"; //file failed to open
}
?>