簡體   English   中英

php虛擬(''); 可以,但是php包括''; 才不是

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

我試圖了解以下內容之間的區別。 我所做的所有閱讀都說“包含”應該起作用。 我想知道“為什么”我必須使用“ 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>
<?php include'/path'; ?>

由於它所在的文件類型而無法使用。此語句必須使用僅在php文件中有效的'virtual()'。 “包含”僅適用於html或shtml文件。

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

用於html文件和

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

用於php文件。

html代碼仍然使用虛擬但也包含include ,因此我仍然不確定為什么不能單獨使用include

-您的第二學期學生

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM