Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem is that you are not producing the correct content with write.php, probably due to a misunderstanding of what includes actually do.</p> <p>All the include() function does is take the contents of the included file and parse it as PHP at the point in the file you include it. It has almost the same effect as cutting and pasting the file contents in the same place. Only put in your included file what you might type where it is to be put.</p> <p>I would rewrite the lot properly so that write.php contains only a function that generates a string of html for your commment boxes:</p> <pre><code>&lt;?PHP function commentbox() { $output=""; for($i=0; $i&lt;3; $i++) $output.="&lt;div class='commentBox' id='cb_$i'&gt;&lt;p&gt; Just a box&lt;/p&gt;&lt;/div&gt;"; return $output; } ?&gt; </code></pre> <p>you include() this at the top of your php file then call its output wherever required by:</p> <pre><code>echo commentbox(); </code></pre> <p>or, better:</p> <p>create a footer.php file:</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 echo $content;?&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>which you can use with all your projects very easily.</p> <p>This is used this way:</p> <pre><code>&lt;?PHP include("write.php"); $content="whatever"; $content.=commentbox(); $content.="whateverelse"; include("footer.php"); ?&gt; </code></pre> <p>Even though I have deliberately gone to no trouble to format the above code, it is very easy to find where the content is being created and to debug it. Mixed PHP and HTML code is a nightmare to debug even with code-context-colouring. It is also very difficult to find the bit you want to borrow and put somewhere else later.</p>
 

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