Normally I am developing website and coding PHP
and HTML
something like this -
while (mysqli_stmt_fetch($stmt)) {
// Create Table Body
$html .= "<tr>
";
$html .= " <td>$title</td>
";
$html .= " <td>$date</td>";
$html .= " <td align='center'>
";
$html .= " <a href='#'>
";
$html .= " <span class='view' title='View This Comment'></span>
";
$html .= " </a>
";
$html .= " </td>
";
$html .= " <td class='td_catchall' align='center'>
";
$html .= " <a href='#'>
";
$html .= " <span class='edit' title='Edit This Comment'></span>
";
$html .= " </a>
";
$html .= " </td>
";
$html .= " <td align='center'>
";
$html .= " <a href='#'>
";
$html .= " <span class='delete' title='Delete This Comment'></span>
";
$html .= " </a>
";
$html .= " </td>
";
$html .= "</tr>
";
}
//Create View Blog Dialog Box
$viewBlog = "<div id='dialog-view'>
";
$viewBlog .= " <h2>$title</h2>
";
$viewBlog .= " <p>$date</p>
";
$viewBlog .= " <p>";
$viewBlog .= " <img src='".UPLOAD_DIR.$userName."/".$image."' />";
$viewBlog .= " $comment</p>";
$viewBlog .= "</div>
";
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.
If it is true, can anybody tell me how can I do it?
Any comments would be greatly appreciated. Thank you.
See Question&Answers more detail:os