Note that there are some explanatory texts on larger screens.

plurals
  1. POHow I separate logic from presentation?
    primarykey
    data
    text
    <p>Normally I am developing website and coding <code>PHP</code> and <code>HTML</code> something like this - </p> <pre><code>while (mysqli_stmt_fetch($stmt)) { // Create Table Body $html .= "&lt;tr&gt;\n"; $html .= " &lt;td&gt;$title&lt;/td&gt;\n"; $html .= " &lt;td&gt;$date&lt;/td&gt;"; $html .= " &lt;td align='center'&gt;\n"; $html .= " &lt;a href='#'&gt;\n"; $html .= " &lt;span class='view' title='View This Comment'&gt;&lt;/span&gt;\n"; $html .= " &lt;/a&gt;\n"; $html .= " &lt;/td&gt;\n"; $html .= " &lt;td class='td_catchall' align='center'&gt;\n"; $html .= " &lt;a href='#'&gt;\n"; $html .= " &lt;span class='edit' title='Edit This Comment'&gt;&lt;/span&gt;\n"; $html .= " &lt;/a&gt;\n"; $html .= " &lt;/td&gt;\n"; $html .= " &lt;td align='center'&gt;\n"; $html .= " &lt;a href='#'&gt;\n"; $html .= " &lt;span class='delete' title='Delete This Comment'&gt;&lt;/span&gt;\n"; $html .= " &lt;/a&gt;\n"; $html .= " &lt;/td&gt;\n"; $html .= "&lt;/tr&gt;\n"; } //Create View Blog Dialog Box $viewBlog = "&lt;div id='dialog-view'&gt;\n"; $viewBlog .= " &lt;h2&gt;$title&lt;/h2&gt;\n"; $viewBlog .= " &lt;p&gt;$date&lt;/p&gt;\n"; $viewBlog .= " &lt;p&gt;"; $viewBlog .= " &lt;img src='".UPLOAD_DIR.$userName."/".$image."' /&gt;"; $viewBlog .= " $comment&lt;/p&gt;"; $viewBlog .= "&lt;/div&gt;\n"; </code></pre> <p>But recently I came across to know one of my friend, that is a bad practice of saving the HTML in a PHP variable. And also said I need to separate logic from presentation. </p> <p>If it is true, can anybody tell me how can I do it? </p> <p>Any comments would be greatly appreciated. Thank you. </p>
    singulars
    1. This table or related slice is empty.
    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.
 

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