Are there alternative methods to validate and filter HTML content in PHP without relying on PHP extensions or external libraries?

When validating and filtering HTML content in PHP without relying on extensions or external libraries, one approach is to use the built-in PHP functions like `strip_tags()` and `htmlspecialchars()` to sanitize input. These functions can help remove potentially harmful content and escape special characters to prevent XSS attacks.

// Example of validating and filtering HTML content without external libraries or extensions
$input = "<p><script>alert('XSS attack')</script></p>";
$filtered_input = strip_tags($input); // Remove any HTML tags
$filtered_input = htmlspecialchars($filtered_input, ENT_QUOTES, 'UTF-8'); // Escape special characters

echo $filtered_input;