There are those occasions when an entire file (text or HTML) must be read from a file and stored in a variable for subsequent use. The following code snippet outlines a function to accomplish the aforementioned premise. Notice the “$fna” parameter. This parameter would contain the file name of the file to be processed. The function returns a variable that contains the entire contents of the file.
The calling sequence would resemble the following:
$bod = ReadHtml(Yii::app()->basepath . ‘/views/sig.html’);
The HTML file “sig.html” is located in the “views” sub directory. The “$bod” variable now contains the file contents entirely.
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems authored this article.