繁体   English   中英

Require_once在PHP脚本中不起作用

[英]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.

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