What are the best practices for creating a printable ticket page in PHP for user interaction?

When creating a printable ticket page in PHP for user interaction, it is important to ensure that the page is properly formatted for printing. This includes setting up the page layout, adding necessary content such as ticket details and a print button, and ensuring that the page is optimized for printing.

<?php
// Start PHP session
session_start();

// Check if ticket details are set in session
if(isset($_SESSION['ticket_details'])) {
    // Output ticket details on the page
    echo '<h1>Ticket Details</h1>';
    echo '<p>' . $_SESSION['ticket_details'] . '</p>';
    
    // Add print button
    echo '<button onclick="window.print()">Print Ticket</button>';
} else {
    echo 'Ticket details not found.';
}
?>