最新消息:

PHP函数第27款:获取PHP模板函数GetTemplates

PHP扩展函数 杨红伟 4153浏览 0评论

一:函数简介

假如我的模板目录下有一个文件叫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 '';
		}
	}
}


Warning: Use of undefined constant PRC - assumed 'PRC' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.ijquery.cn/wp-content/themes/d8-3.0/comments.php on line 17
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址