What are the best practices for setting headers in PHP to ensure successful PDF file display in browsers?

When displaying PDF files in browsers using PHP, it is important to set the correct headers to ensure successful rendering. This includes setting the Content-Type header to "application/pdf" and Content-Disposition header to "inline" to prompt the browser to display the PDF file within the browser window rather than downloading it.

// Set headers for displaying PDF file in browser
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="example.pdf"');

// Output the PDF file content
readfile('path/to/example.pdf');