简体   繁体   English

php虚拟(''); 可以,但是php包括''; 才不是

[英]php virtual (''); works but php include''; does not

I'm trying to understand the difference between the following. 我试图了解以下内容之间的区别。 All of the reading I've done says that 'include' should work. 我所做的所有阅读都说“包含”应该起作用。 I'm wondering 'why' I have to use the 'virtual()' and/or WHAT I'm doing wrong with the 'include'. 我想知道“为什么”我必须使用“ virtual()”和/或“ include”我做错了什么。

<?php virtual('/path'); ?>

and

<?php include'/path'; ?>

I use both in the code below. 我在下面的代码中都使用。 The 'virtual()' works and is used for header.php. 'virtual()'有效并且用于header.php。 The 'include' (does not work) and is used for footer.php. 'include'(无效),用于footer.php。 The code for the entire page is below. 整个页面的代码如下。 Link to live page 链接到实时页面

<head>
<title>Untitled Document</title>
<link href="/student_sites/2013/web_40/pages/css_includes/css_includes.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
  <div id="header"><?php virtual('/student_sites/2013/web_40/pages/css_includes/assets/includes/header.php'); ?>
</div>
  <div id="content_wrapper">Content for New CONTENT WRAPPER Div Tag Goes Here
<div id="side_bar">Content for New SIDE BAR Div Tag Goes Here</div>
    <div id="content">Content for New CONTENT Div Tag Goes Here</div>
  </div>
  <div id="footer"><?php include '/student_sites/2013/web_40/pages/css_includes/assets/includes/footer.php'; ?></div>
</div>
</body>
</html>
<?php include'/path'; ?>

Doesn't work because of the type of file it's in. This statement must use the 'virtual()' which only works in php files. 由于它所在的文件类型而无法使用。此语句必须使用仅在php文件中有效的'virtual()'。 The 'include' only works in html or shtml files. “包含”仅适用于html或shtml文件。

<!--#include virtual="/path" -->

for html files and 用于html文件和

<?php virtual('/path'); ?>

for php files. 用于php文件。

The html code still uses virtual but include as well, so I'm still not sure why it can't use include by itself. html代码仍然使用虚拟但也包含include ,因此我仍然不确定为什么不能单独使用include

-your 2ed period stutent -您的第二学期学生

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM