What are the best practices for filtering HTML content before storing it in a database in PHP?

When storing HTML content in a database in PHP, it is important to filter the content to prevent potential security vulnerabilities such as XSS attacks. One common approach is to use the `strip_tags()` function to remove any HTML tags from the content before storing it in the database. Additionally, you can use `htmlspecialchars()` to encode special characters in the content to prevent script injection.

// Example of filtering HTML content before storing it in a database
$htmlContent = "<p>This is some <b>bold</b> text with a <script>alert('XSS attack')</script></p>";

// Strip HTML tags from the content
$filteredContent = strip_tags($htmlContent);

// Encode special characters to prevent script injection
$filteredContent = htmlspecialchars($filteredContent);

// Store the filtered content in the database
// $stmt = $pdo->prepare("INSERT INTO table_name (content) VALUES (:content)");
// $stmt->bindParam(':content', $filteredContent);
// $stmt->execute();