#include 指令文件引用

 时间:2024-10-12 16:24:51

#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" 文件:

"人参皂苷rh2:One should never increase heaa.taobao.com, 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 explainnythi-人参皂苷rh2:jiankang567.com/html/tu01.htmng."</p><h2>The time is:</h2><p>11:33:42 AM</p></body></html>

Including 文件的语法:

如需在 ASP 中引用文件,请把 #include 命令置于注释标签之中:

<!--#include virtual="somefilename"-->

或者:

<!--#include file ="somefilename"-->

关键词 Virtual

关键词 virtual 指示路径以虚拟目录开始。

如果 "header.inc" 文件位于虚拟目录 /html 中,下面这行代码会插入文件 "header.inc" 中的内容:

<!-- #includevirtual="/html/header.inc" -->

关键词 File

关键词 File 指示一个相对的路径。相对路径起始于含有引用文件的目录。

假设文件位于 html 文件夹的子文件夹 headers 中,下面这段代码可引用 "header.inc" 文件的内容:

<!-- #includefile="headers\header.inc" -->

  • 原神稻妻寻找结界任务的玩法攻略
  • Altium使用:[3]原理图
  • 原神鹿野院平藏技能天赋命座信息介绍详解
  • 原神的圣遗物怎样升级升级?
  • 《原神》蝴蝶晶核哪里多
  • 热门搜索
    关于名人的手抄报 端午节手抄报第一名 父亲节手抄报图片 拒绝舌尖上的浪费手抄报 感恩老师手抄报内容 读书日手抄报 手抄报版面设计花边 防控疫情的手抄报 新学期新希望手抄报 文明出行手抄报