=htmlspecialchars($single_post['title']);?>
=htmlspecialchars($single_post['content']);?>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
ตัวอย่างโค้ด PHP
<?php
class BlogPost {
private $title;
private $content;
private $author;
public function __construct($title, $content, $author) {
$this->title = $title;
$this->content = $content;
$this->author = $author;
}
public function getTitle() {
return $this->title;
}
public function display() {
echo "<h2>" . htmlspecialchars($this->title) . "</h2>";
echo "<p>" . htmlspecialchars($this->content) . "</p>";
echo "<small>โดย: " . htmlspecialchars($this->author) . "</small>";
}
}
// การใช้งาน
$post = new BlogPost(
"หัวข้อบทความ",
"เนื้อหาบทความ...",
"ชื่อผู้เขียน"
);
$post->display();
?>