How can CSS be inline styled in HTML emails generated by PHP scripts?

When generating HTML emails using PHP scripts, inline styling is often preferred over external CSS files to ensure email client compatibility. To inline style CSS in HTML emails generated by PHP scripts, you can use the PHP `style` function to dynamically apply CSS styles directly to HTML elements.

// Example PHP code snippet to inline style CSS in HTML emails generated by PHP scripts

// Define your CSS styles
$css = "
    body {
        background-color: #f0f0f0;
        font-family: Arial, sans-serif;
    }
    .header {
        color: #333333;
        font-size: 24px;
    }
";

// Apply inline styles to HTML elements
$html = "
    <html>
    <head>
        <title>Email Template</title>
    </head>
    <body style='background-color: #f0f0f0; font-family: Arial, sans-serif;'>
        <div class='header' style='color: #333333; font-size: 24px;'>Hello, World!</div>
    </body>
    </html>
";

// Output the HTML content
echo $html;