Below is the code which can be used to read any file using php.
This code will return the data of the file.
The output data can be used as per the requirement
<?php
function FileRead($filename)
{
$return = '';
if ($fp = fopen($filename, 'rb')) {
while (!feof($fp)) {
$return .= fread($fp, 1024);
}
fclose($fp);
// return $return;
echo $return;
} else {
// return false;
}
}
FileRead("sample.html");
?>
This code will return the data of the file.
The output data can be used as per the requirement
<?php
function FileRead($filename)
{
$return = '';
if ($fp = fopen($filename, 'rb')) {
while (!feof($fp)) {
$return .= fread($fp, 1024);
}
fclose($fp);
// return $return;
echo $return;
} else {
// return false;
}
}
FileRead("sample.html");
?>
No comments:
Post a Comment