What are the best practices for generating HTML code with PHP for jQuery Mobile integration?

When generating HTML code with PHP for jQuery Mobile integration, it is important to ensure that the HTML elements are properly structured and formatted to work seamlessly with jQuery Mobile's framework. To achieve this, it is recommended to use PHP to dynamically generate the necessary HTML elements with the appropriate data attributes and classes required by jQuery Mobile.

<?php
// Start by echoing the HTML document structure
echo '<!DOCTYPE html>';
echo '<html>';
echo '<head>';
echo '<meta charset="utf-8">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
echo '<title>jQuery Mobile Integration</title>';
echo '<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">';
echo '<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>';
echo '<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>';
echo '</head>';
echo '<body>';

// Dynamically generate a jQuery Mobile page
echo '<div data-role="page" id="page1">';
echo '<div data-role="header">';
echo '<h1>My Page</h1>';
echo '</div>';
echo '<div data-role="main" class="ui-content">';
echo '<p>This is a jQuery Mobile page generated with PHP.</p>';
echo '</div>';
echo '</div>';

echo '</body>';
echo '</html>';
?>