本站资源均来自互联网,仅供学习与参考,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
Copyright @ 2015-2020 织梦园 版权所有
Power by DedeCms
鲁ICP备15039853号-1
鲁公网安备 37132302000249号
模板标签 TAG标签 网站地图 XML地图 今日更新 返回顶部
织梦dedecms主要功能是读取远程页面的代码放到需要调用的地方。
可以代替织梦dedecms系统默认的include标签使用。
系统默认的include只能读取本地文件。
而我所写的readfile标签,能读取远程文件。
代码很简单,不过,也很实用
使用方法:{dede:readfile url='需要读取的页面地址'}{/dede:readfile}
在织梦dedecms织梦模板管理里面,新建标签源码,文件名为:readfile.lib.php
代码如下:
<?php if(!defined('DEDEINC')) { exit("Request Error!"); } function lib_readfile(&$ctag,&$refObj) { global $dsql,$envs; //属性处理 $attlist="url|"; FillAttsDefault($ctag->CAttribute->Items,$attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); if($url != '') { $contents = file_get_contents($url); //如果出现中文乱码使用下面代码 //$contents = iconv(”gb2312″, “utf-8″,file_get_contents($url)); } else{ $contents = '远程地址不能为空'; } $revalue = $contents; return $revalue; } ?> |