通常我正在开发网站和编码PHP
以及HTML
类似的东西 -
while (mysqli_stmt_fetch($stmt)) {
// Create Table Body
$html .= "<tr>\n";
$html .= " <td>$title</td>\n";
$html .= " <td>$date</td>";
$html .= " <td align='center'>\n";
$html .= " <a href='#'>\n";
$html .= " <span class='view' title='View This Comment'></span>\n";
$html .= " </a>\n";
$html .= " </td>\n";
$html .= " <td class='td_catchall' align='center'>\n";
$html .= " <a href='#'>\n";
$html .= " <span class='edit' title='Edit This Comment'></span>\n";
$html .= " </a>\n";
$html .= " </td>\n";
$html .= " <td align='center'>\n";
$html .= " <a href='#'>\n";
$html .= " <span class='delete' title='Delete This Comment'></span>\n";
$html .= " </a>\n";
$html .= " </td>\n";
$html .= "</tr>\n";
}
//Create View Blog Dialog Box
$viewBlog = "<div id='dialog-view'>\n";
$viewBlog .= " <h2>$title</h2>\n";
$viewBlog .= " <p>$date</p>\n";
$viewBlog .= " <p>";
$viewBlog .= " <img src='".UPLOAD_DIR.$userName."/".$image."' />";
$viewBlog .= " $comment</p>";
$viewBlog .= "</div>\n";
但最近我认识了我的一个朋友,将 HTML 保存在 PHP 变量中是一种不好的做法。并且还说我需要将逻辑与演示分开。
如果是真的,谁能告诉我我该怎么做?
任何意见将不胜感激。谢谢你。