一:函数简介
假如我的模板目录下有一个文件叫templates.html,我想查看它的内容并显示在我网页上,该怎么操作?这款函数帮了我们的大忙。
演示地址: http://www.ijquery.cn/phpfunction/GetTemplates/demo1.php
下载地址: http://www.ijquery.cn/phpfunction/GetTemplates/GetTemplates.zip
二:函数应用
echo GetTemplets("templates.html");
返回的结果是 templates.html的内容
hello world!
三:函数源代码
/** * 获取模板 * * @param string $filename 文件名称 * @return string */ if (!function_exists('GetTemplets')) { function GetTemplets($filename) { if (file_exists($filename)) { $fp = fopen($filename, "r"); $rstr = fread($fp, filesize($filename)); fclose($fp); return $rstr; } else { return ''; } } }