0

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>";
1
  • Is allow_url_fopen enabled? Normally it's not so you can't include/require remote files (which is a hideous security hole) Commented Feb 3, 2011 at 14:05

2 Answers 2

1

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>";
Sign up to request clarification or add additional context in comments.

1 Comment

Didn't even catch that the URL is external. This may cause a problem, like noted in the initial comment above. require_once looks for a local file, i.e: /pluginfiles/files/v101/v101.php not a URL.
1

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>

3 Comments

Just make sure that if this is just a chuck of a larger file using PHP, you need to use a php end tag, and opening tag again before and after. i.e: ?>TrickerAnswerHere<?php
He is tellin he is using Wordpress, and in that case i would use it like this. Because Wordpress is using it in this way. But if there is MORE PHP then HTML then i should do it with a echo
Thanks tricker this worked perfectly as well as with the repsonse with david :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.