服务器端包含 [英] Server-Side Includes

查看:78
本文介绍了服务器端包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我指的是学习ASP的书,说明以下关于服务器 -

方包括:


========== ====================================

服务器中的代码 - 在包含页面的ASP代码被评估之前,将包含文件的内容插入到页面中。

使用它。这意味着你可以将
放在包含文件中,并且它将像

一样执行它是包含它的页面的一部分。另一方面,它意味着你不能用ASP来确定要包含的页面。

=============== ===============================


但与最后一行相反在上面的段落中,以下代码

使用ASP来确定要包含的页面:


<%

Dim intA,intB


intA = 5

intB = 6

If(intA> intB)Then

%>

<! - #include file =" File1.inc" - >

<%

Else

%>

<! - #include file =" File2.inc" - >

<%

结束如果

%>


File1.inc只有一行 - 这是File1 。

同样,File2.inc也只有一行 - 这是File2。


现在,由于上面代码中的If条件求值为False,

File2.inc包括在内&因此浏览器显示


这是File2。


但是如果我将intA的值更改为,比方说10,那么If

条件评估为True,然后File1.inc包含&

因此浏览器显示


这是File1。


因此,我从ASP

书中引用的上述段落中的最后一行是错误的吗?

The book I am referring to learn ASP states the following about server-
side includes:

==============================================
The code in a server-side include file is inserted into the pages that
use it BEFORE the page''s ASP code is evaluated. This means that you
can put ASP code inside the include file, and it will be executed like
it was part of the page that includes it. On the other hand, it means
that you cannot use ASP to determine which page to include.
==============================================

But as opposed to the last line in the above para, the following code
makes use of ASP to determine which page to include:

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
<!-- #include file="File1.inc"-->
<%
Else
%>
<!-- #include file="File2.inc"-->
<%
End If
%>

File1.inc has only one line - This is File1.
Similarly, File2.inc also has only one line - This is File2.

Now since the If condition in the above code evaluates to False,
File2.inc gets included & hence the browser displays

This is File2.

But if I change the value of intA to, say, 10, so that the If
condition evaluates to True, then File1.inc gets included &
consequently the browser displays

This is File1.

So isn''t the last line in the above para which I cited from the ASP
book wrong?

推荐答案

RN1写道:
RN1 wrote:

我所指的学习ASP的书陈述以下关于

服务器端包括:


================================= =============

服务器端包含文件中的代码被插入页面中

在页面之前使用它评估ASP代码。这意味着你可以将
放在包含文件中,并且它将像

一样执行它是包含它的页面的一部分。另一方面,它意味着你不能用ASP来确定要包含的页面。

=============== ===============================


但与最后一行相反在上面的段落中,以下代码

使用ASP来确定要包含的页面:


<%

Dim intA,intB


intA = 5

intB = 6

If(intA> intB)Then

%>

<! - #include file =" File1.inc" - >

<%

Else

%>

<! - #include file =" File2.inc" - >

<%

结束如果

%>


File1.inc只有一行 - 这是File1 。

同样,File2.inc也只有一行 - 这是File2。


现在,由于上面代码中的If条件求值为False,

File2.inc包括在内&因此浏览器显示


这是File2。


但是如果我将intA的值更改为,比方说10,那么If

条件评估为True,然后File1.inc包含&

因此浏览器显示


这是File1。


所以,我从ASP

书中引用的上述段落的最后一行是不是错了?
The book I am referring to learn ASP states the following about
server- side includes:

==============================================
The code in a server-side include file is inserted into the pages that
use it BEFORE the page''s ASP code is evaluated. This means that you
can put ASP code inside the include file, and it will be executed like
it was part of the page that includes it. On the other hand, it means
that you cannot use ASP to determine which page to include.
==============================================

But as opposed to the last line in the above para, the following code
makes use of ASP to determine which page to include:

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
<!-- #include file="File1.inc"-->
<%
Else
%>
<!-- #include file="File2.inc"-->
<%
End If
%>

File1.inc has only one line - This is File1.
Similarly, File2.inc also has only one line - This is File2.

Now since the If condition in the above code evaluates to False,
File2.inc gets included & hence the browser displays

This is File2.

But if I change the value of intA to, say, 10, so that the If
condition evaluates to True, then File1.inc gets included &
consequently the browser displays

This is File1.

So isn''t the last line in the above para which I cited from the ASP
book wrong?



编号。他们都被处理了。
http://classicasp.aspfaq.com/files/d...ude-files.html


-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

NO SPAM

No. They are both processed.
http://classicasp.aspfaq.com/files/d...ude-files.html

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"




RN1 ; < rn ** @ rediffmail.com写信息

新闻:6f **************************** ****** @ d27g2000 prf.googlegroups.com ...

"RN1" <rn**@rediffmail.comwrote in message
news:6f**********************************@d27g2000 prf.googlegroups.com...

我所指的学习ASP的书陈述以下关于服务器的内容 -

方包括:


=============================== ===============

服务器端包含文件中的代码插入到

使用它之前的页面中页面的ASP代码被评估。这意味着你可以将
放在包含文件中,并且它将像

一样执行它是包含它的页面的一部分。另一方面,它意味着你不能用ASP来确定要包含的页面。

=============== ===============================


但与最后一行相反在上面的段落中,以下代码

使用ASP来确定要包含的页面:


<%

Dim intA,intB


intA = 5

intB = 6

If(intA> intB)Then

%>

<! - #include file =" File1.inc" - >

<%

Else

%>

<! - #include file =" File2.inc" - >

<%

结束如果

%>


File1.inc只有一行 - 这是File1 。

同样,File2.inc也只有一行 - 这是File2。


现在,由于上面代码中的If条件求值为False,

File2.inc包括在内&因此浏览器显示


这是File2。


但是如果我将intA的值更改为,比方说10,那么If

条件评估为True,然后File1.inc包含&

因此浏览器显示


这是File1。


所以,我从ASP

书中引用的上述段落的最后一行是不是错了?
The book I am referring to learn ASP states the following about server-
side includes:

==============================================
The code in a server-side include file is inserted into the pages that
use it BEFORE the page''s ASP code is evaluated. This means that you
can put ASP code inside the include file, and it will be executed like
it was part of the page that includes it. On the other hand, it means
that you cannot use ASP to determine which page to include.
==============================================

But as opposed to the last line in the above para, the following code
makes use of ASP to determine which page to include:

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
<!-- #include file="File1.inc"-->
<%
Else
%>
<!-- #include file="File2.inc"-->
<%
End If
%>

File1.inc has only one line - This is File1.
Similarly, File2.inc also has only one line - This is File2.

Now since the If condition in the above code evaluates to False,
File2.inc gets included & hence the browser displays

This is File2.

But if I change the value of intA to, say, 10, so that the If
condition evaluates to True, then File1.inc gets included &
consequently the browser displays

This is File1.

So isn''t the last line in the above para which I cited from the ASP
book wrong?



根据书中的说法,你的页面会在它被解析并作为ASP页面执行之前显示为:
: -


<%

Dim intA,intB


intA = 5

intB = 6


如果(intA> intB)那么

%>

这是File1。

<%

否则

%>

这是File2。

<%

结束如果

%>


正如您所看到的那样,两个包含都被添加了。尝试将

file2的内容更改为: -


<%

结束如果

%>

这是File2。

<%

如果错,那么

%>


解析前生成的文件变为: -


<%

Dim intA,intB


intA = 5

intB = 6

如果(intA> intB)那么

% >

这是File1。

<%

否则

%>


<%

结束如果

%>

这是File2。

<%

如果错误那么

%>

<%

结束如果

%>


结果输出为: -


这是File1。

这是File2。


-

Anthony Jones - MVP ASP / ASP.NET

According the what the book says your page will look like this before it is
parsed and executed as an ASP page:-

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
This is File1.
<%
Else
%>
This is File2.
<%
End If
%>

As you can see both includes have been added. Try changing the content of
file2 to this:-

<%
End If
%>
This is File2.
<%
If False Then
%>

The resulting file before parsing becomes:-

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
This is File1.
<%
Else
%>

<%
End If
%>
This is File2.
<%
If False Then
%>
<%
End If
%>

The resulting output is:-

This is File1.
This is File2.

--
Anthony Jones - MVP ASP/ASP.NET


在12月16日下午9:22,Bob Barrows [MVP] < reb01 ... @ NOyahoo.SPAMcom>

写道:
On Dec 16, 9:22 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:

RN1写道:
RN1 wrote:

我所指的学习ASP的书说明以下关于

服务器端包括:
The book I am referring to learn ASP states the following about
server- side includes:


==============================================
服务器端包含文件中的代码插入到页面中,在页面的ASP代码被评估之前,b $ b使用它。这意味着你可以将
放在包含文件中,并且它将像

一样执行它是包含它的页面的一部分。另一方面,它意味着你不能用ASP来确定要包含的页面。

=============== ===============================
==============================================
The code in a server-side include file is inserted into the pages that
use it BEFORE the page''s ASP code is evaluated. This means that you
can put ASP code inside the include file, and it will be executed like
it was part of the page that includes it. On the other hand, it means
that you cannot use ASP to determine which page to include.
==============================================


但与上面para中的最后一行相反,以下代码

使用ASP来确定要包含的页面:
But as opposed to the last line in the above para, the following code
makes use of ASP to determine which page to include:


<%

Dim intA,intB
<%
Dim intA,intB


intA = 5

intB = 6
intA=5
intB=6


如果(intA> intB)那么

%>

< ;! - #include file =" File1.inc" - >

<%

Else

%>

<! - #include file =" File2.inc" - >

<%

结束如果

%>
If(intA>intB) Then
%>
<!-- #include file="File1.inc"-->
<%
Else
%>
<!-- #include file="File2.inc"-->
<%
End If
%>


File1.inc只有一行 - 这是File1。

同样,File2.inc也只有一行 - 这是File2。
File1.inc has only one line - This is File1.
Similarly, File2.inc also has only one line - This is File2.


现在,由于上述代码中的If条件的计算结果为False,

File2.inc包括在内&因此浏览器显示
Now since the If condition in the above code evaluates to False,
File2.inc gets included & hence the browser displays


这是File2。
This is File2.


但是如果我将intA的值更改为,例如10,那么If

条件的计算结果为True ,然后包含File1.inc&

因此浏览器显示
But if I change the value of intA to, say, 10, so that the If
condition evaluates to True, then File1.inc gets included &
consequently the browser displays


这是File1。
This is File1.


因此,我从ASP

书中引用的上述段落中的最后一行是错误的吗?
So isn''t the last line in the above para which I cited from the ASP
book wrong?



编号。他们都被处理。 http://classicasp.aspfaq.com/files/d...do-i-dynamical ...


-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

无垃圾邮件 - 隐藏引用文字 -


- 显示引用文字 -


No. They are both processed.http://classicasp.aspfaq.com/files/d...do-i-dynamical...

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"- Hide quoted text -

- Show quoted text -



这个新闻组出了点问题。列出所有

帖子的页面显示此帖子中有3个帖子& Bob&安德鲁斯

已经回答了我的帖子,但我在任何地方都找不到安德鲁的回复!!

Something''s wrong with this newsgroup. The page which lists all the
posts says that there are 3 threads in this post & that Bob & Andrews
have answered my post but I don''t find Andrew''s response anywhere!!


这篇关于服务器端包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆