This PHP program is to read a text file and display in HTML
This is my text file i have saved it in the same folder where my php program is. you can save it at any place but you have to give the complete path for the file
SOURCE CODE :
<!DOCTYPE html>
<html>
<body>
<?php
//vivek.txt is my file name replace it with your file name
$myfile = fopen("vivek.txt", "r") or die("Unable to open file!");
// Output one line until end-of-file
while(!feof($myfile)) {
echo fgets($myfile) . "<br>";
}
fclose($myfile);
?>
</body>
</html>
OUTPUT :
This is my text file i have saved it in the same folder where my php program is. you can save it at any place but you have to give the complete path for the file
SOURCE CODE :
<!DOCTYPE html>
<html>
<body>
<?php
//vivek.txt is my file name replace it with your file name
$myfile = fopen("vivek.txt", "r") or die("Unable to open file!");
// Output one line until end-of-file
while(!feof($myfile)) {
echo fgets($myfile) . "<br>";
}
fclose($myfile);
?>
</body>
</html>
OUTPUT :
No comments:
Post a Comment