简体   繁体   中英

Require_once not working in PHP script

I am making a wordpress plugin and I am having a little issue with this paragraph of code. For some reason

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>";

Don't put the require into the echo, or it will just display the text and not parse the function. You need to end the echo with a "; then the require, and then output again. Or you can use echo "something" . require(blah) . "end"; but I didn't use this for simplicities sake. Also, the require uses a local path/file not remote. This is the equivelent of trying to open a URL in Notepad on your computer, when its looking for something on your hard drive instead.

// 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>";

why echo a whole string and not without and only <?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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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