0

我试图了解以下内容之间的区别。我所做的所有阅读都表明“包含”应该有效。我想知道'为什么'我必须使用'virtual()'和/或我在'include'上做错了什么。

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

<?php include'/path'; ?>

我在下面的代码中同时使用了两者。'virtual()' 工作并用于 header.php。'include'(不起作用)用于footer.php。整个页面的代码如下。 链接到实时页面

<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>
4

1 回答 1

1
<?php include'/path'; ?>

由于它所在的文件类型而不起作用。此语句必须使用仅适用于 php 文件的“virtual()”。“包含”仅适用于 html 或 shtml 文件。

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

对于 html 文件和

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

用于 php 文件。

html代码仍然使用virtual但也包含,所以我仍然不确定为什么它不能单独使用include

-你的 2ed 期学生

于 2014-03-04T16:55:19.117 回答