[英]Require_once not working in PHP script
我正在制作一個wordpress插件,但這段代碼有一個小問題。 由於某些原因
echo "<table style='border:solid 1px #000000;'>
<tr>
<td style='border:solid 1px #000000;'>Total Submission Sites</td>
<td style='border:solid 1px #000000;'>Server Status</td>
<td style='border:solid 1px #000000;'>Plugin Version</td>
<td style='border:solid 1px #000000;'>Latest Update</td>
</tr>
<tr>
<td style='border:solid 1px #000000;'>test</td>
<td style='border:solid 1px #000000;'>test</td>
<td style='border:solid 1px #000000;'>test</td>
<td style='border:solid 1px #000000;'> <?php require_once('http://wert.in/pluginfiles/files/v101/v101.php') ?></td>
</tr>
</table>";
不要將require放入echo中,否則它只顯示文本而不解析函數。 您需要在回聲后面加上一個“;然后是require,然后再次輸出。或者您可以使用echo” something“。require(blah)。” end“;但是為了簡單起見,我沒有使用它。此外, require使用本地路徑/文件而不是遠程文件,這等效於在硬盤上查找記事本時嘗試在計算機上的記事本中打開URL。
// start the echo
echo "<table style='border:solid 1px #000000;'>
<tr>
<td style='border:solid 1px #000000;'>Total Submission Sites</td>
<td style='border:solid 1px #000000;'>Server Status</td>
<td style='border:solid 1px #000000;'>Plugin Version</td>
<td style='border:solid 1px #000000;'>Latest Update</td>
</tr>
<tr>
<td style='border:solid 1px #000000;'>test</td>
<td style='border:solid 1px #000000;'>test</td>
<td style='border:solid 1px #000000;'>test</td>
<td style='border:solid 1px #000000;'>";
// Still using php, dont need the opening tag.
require_once('http://wert.in/pluginfiles/files/v101/v101.php');
// Finish the echo
echo "</td>
</tr>
</table>";
為什么回顯一個完整的字符串,而不是只有<?php require_once( [.....] ); ?>
<?php require_once( [.....] ); ?>
<table style='border:solid 1px #000000;'>
<tr>
<td style='border:solid 1px #000000;'>Total Submission Sites</td>
<td style='border:solid 1px #000000;'>Server Status</td>
<td style='border:solid 1px #000000;'>Plugin Version</td>
<td style='border:solid 1px #000000;'>Latest Update</td>
</tr>
<tr>
<td style='border:solid 1px #000000;'>test</td>
<td style='border:solid 1px #000000;'>test</td>
<td style='border:solid 1px #000000;'>test</td>
<td style='border:solid 1px #000000;'><?php require_once('./pluginfiles/files/v101/v101.php') ?></td>
</tr>
</table>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.