May 082012
 

To read and return the content of a file. Not included are any exceptions that one might like to add.

 

/**
* Read and return the contents of a file
**/
function getFileContents($fileName) {

  $handle = fopen($fileName,'r');
  $contents = ((filesize($fileName)) > 0) ? fread($handle, filesize($fileName)) : "";
  $fclose($handle);

  return $contents;
}
 Posted by at 5:12 am