What role do headers play in displaying a PDF file in PHP, and can you provide an example?

Headers play a crucial role in displaying a PDF file in PHP by specifying the content type of the response to be "application/pdf" and triggering the browser to interpret the response as a PDF file. Without setting the correct headers, the browser may try to display the PDF content as text or HTML, resulting in a corrupted or unreadable display. Here is an example of how to set the appropriate headers to display a PDF file in PHP:

```php
<?php
// Path to the PDF file
$pdf_file = 'path/to/your/file.pdf';

// Set the appropriate headers
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . basename($pdf_file) . '"');
header('Content-Length: ' . filesize($pdf_file));

// Output the PDF file
readfile($pdf_file);
```

This code snippet sets the necessary headers for displaying a PDF file inline in the browser, retrieves the file content using `readfile()`, and outputs it to the browser.