What are some best practices for displaying PHP output on a webpage?
When displaying PHP output on a webpage, it is important to ensure that the output is properly formatted and sanitized to prevent any security vulnerabilities. One best practice is to use htmlspecialchars() function to escape any special characters in the output before displaying it on the webpage.
<?php
$output = "<script>alert('XSS attack!');</script>";
echo htmlspecialchars($output);
?>