Shaquille Ray
Shaquille Ray

Reputation: 183

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

Upvotes: 0

Views: 1279

Answers (2)

Yoram de Langen
Yoram de Langen

Reputation: 5499

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

Upvotes: 1

David Houde
David Houde

Reputation: 4778

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

Upvotes: 1

Related Questions