标题: ASP 文件引用 [打印本页] 作者: vicky.yu 时间: 2019-9-27 10:52 标题: ASP 文件引用
#include 指令用于在多重页面上创建需重复使用的函数、页眉、页脚或者其他元素等。
#include 指令
通过使用 #include 指令,我们可以在服务器执行 ASP 文件之前,把另一个ASP文件插入这个文件中。#include 命令用于在多个页面上创建需要重复使用的函数、页眉、页脚或者其他元素等。
如何使用 #include 指令
这里有一个名为 "mypage.asp" 的文件:
<html>
<body>
<h2>Words of Wisdom:</h2>
<p><!--#include file="wisdom.inc"--></p>
<h2>The time is:</h2>
<p><!--#include file="time.inc"--></p>
</body>
</html>
这是 "wisdom.inc" 文件:
"One should never increase, beyond what is necessary,
the number of entities required to explain anything."
这是 "time.inc" 文件:
<%
Response.Write(Time)
%>
在浏览器中查看的源代码应该类似这样:
<html>
<body>
<h2>Words of Wisdom:</h2>
<p>"One should never increase, beyond what is necessary,
the number of entities required to explain anything."</p>
<h2>The time is:</h2>
<p>11:33:42 AM</p>
</body>
</html>
Including 文件的语法:
如需在 ASP 中引用文件,请把 #include 命令置于注释标签之中: