受<! #include file="filename.asp" --> 宏限制,必须存在该文件并且会预先编译(不管前面是否加以条件) 

经常有这样的要求,根据不同的需求要求include不同的文件,如各个人的不同设置,所以要求能动态include文件。 

代码如下:
 复制代码 代码如下:
Function include(filename) 
 Dim re,content,fso,f,aspStart,aspEnd 

 set fso=CreateObject("Scripting.FileSystemObject") 
 set f=fso.OpenTextFile(server.mappath(filename)) 
 content=f.ReadAll 
 f.close 
 set f=nothing 
 set fso=nothing 

 set re=new RegExp 
 re.pattern="^\s*=" 
 aspEnd=1 
 aspStart=inStr(aspEnd,content,"<%")+2 
 do while aspStart>aspEnd+1  
  Response.write Mid(content,aspEnd,aspStart-aspEnd-2) 
  aspEnd=inStr(aspStart,content,"%\>")+2 
  Execute(re.replace(Mid(content,aspStart,aspEnd-aspStart-2),"Response.Write ")) 
  aspStart=inStr(aspEnd,content,"<%")+2 
 loop 
 Response.write Mid(content,aspEnd)  
 set re=nothing 
End Function 

使用范例: 
复制代码 代码如下:
include("youinc.asp") 
标签:
asp动态include文件,方便多模板的实现

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
白云城资源网 Copyright www.dyhadc.com

评论“asp动态include文件,方便多模板的实现”

暂无“asp动态include文件,方便多模板的实现”评论...

P70系列延期,华为新旗舰将在下月发布

3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。

而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?

根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。