Thursday, June 28, 2007

PHP- Read contents of a text file

#############################################################################
# Function to Read contents of a text file
# Usage: $objClass->fnReadFromFile('filename.txt');# ############################################################################
function fnReadFromFile($sFileName)
{
$sReturn = '';
$fHandle = fopen($sFileName, "r");
while (!feof($fHandle))
$sReturn .= fread($fHandle, 4096);
fclose($fHandle);
return($sReturn);
}

Disclaimer: Any code or advice given is for instructional purposes only. We will not be responsible for any loss or damage caused by using this script.

No comments: