What potential pitfalls should be considered when using PHP to display multimedia content?

One potential pitfall when using PHP to display multimedia content is the risk of security vulnerabilities, such as cross-site scripting (XSS) attacks. To mitigate this risk, it's important to properly sanitize user input and validate file types before displaying multimedia content on a website.

// Example code to sanitize user input and validate file types before displaying multimedia content
$allowed_file_types = array('jpg', 'jpeg', 'png', 'gif');

if(isset($_GET['file']) && in_array(pathinfo($_GET['file'], PATHINFO_EXTENSION), $allowed_file_types)) {
    $file = $_GET['file'];
    echo '<img src="uploads/' . $file . '" alt="Multimedia Content">';
} else {
    echo 'Invalid file type.';
}