Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>&lt;?php if (isset($_GET['outputHtml'])) { echo "&lt;p class='commentBox'&gt;" . "This is from external PHP" . "&lt;/p&gt;"; echo "&lt;p class='commentBox'&gt;" . "This is also from external PHP" . "&lt;/p&gt;"; include 'writephp.php'; } </code></pre> <p>This in your write.php is not correct, see <code>writephp.php</code> is a complete HTML page with <code>&lt;html&gt;</code> <code>&lt;head&gt;</code> and <code>&lt;body&gt;</code> tags and you are including it after echoing some <code>&lt;p&gt;</code> tags, that won't make your new boxes appear magically inside the body of the page, you would be creating some invalid markup with the two <code>&lt;p&gt;</code> at the beginning of the file followed by the <code>&lt;!DOCTYPE&gt;&lt;html&gt;</code> etc...</p> <p><strong>EDIT</strong></p> <p>Regarding the update to your question that now reads <strong>"How place output from an external php file to a specific place on the page"</strong></p> <p>As @Robert Seddon-Smith correctly noted in his answer, using <code>include</code> will make the content appear exactly at the point when the call is made, so if you wanted to include your new boxes in your main file then the call to <code>include</code> should be backwards, that is, you should include the content inside the main file, you can use this example to test it:</p> <p>Modify <code>write.php</code> to just echo the boxes when the $_GET variable is present</p> <pre><code>&lt;?php if (isset($_GET['outputHtml'])) { echo "&lt;div class='commentBox'&gt;" . "This is from external PHP" . "&lt;/div&gt;"; echo "&lt;div class='commentBox'&gt;" . "This is also from external PHP" . "&lt;/div&gt;"; } ?&gt; </code></pre> <p>And make the include call in your main file <code>writephp.php</code> </p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Test Php &lt;/title&gt; &lt;link rel="stylesheet" href="writephp.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="allContent"&gt; &lt;?php for($i=0; $i&lt;3; $i++): ?&gt; &lt;div class="commentBox"&gt; &lt;p&gt; Just a box&lt;/p&gt; &lt;/div&gt; &lt;?php endfor; ?&gt; &lt;?php include 'write.php'?&gt; &lt;a href="writephp.php?outputHtml"&gt;Php output&lt;/a&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This will include your two new boxes inside the container when you click in the link. </p> <p>Also you will note that there is nothing special about styling content from an included file, that is because in the end all the markup is rendered as a single HTML page, it doesn't matter if the content is echoed from the main page or the included file, it will obey any rules in your CSS</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload