How can PHP variables be securely passed to CSS files for dynamic design customization?

When passing PHP variables to CSS files for dynamic design customization, one way to securely do this is by using inline CSS styles within the HTML document. By echoing PHP variables directly into the style attribute of HTML elements, the variables can be dynamically applied to the design without exposing them in an external CSS file.

<?php
// PHP variable to be passed to CSS
$color = "#ff0000";
?>

<!DOCTYPE html>
<html>
<head>
    <style>
        .custom-element {
            color: <?php echo $color; ?>;
        }
    </style>
</head>
<body>
    <div class="custom-element">Dynamic text color</div>
</body>
</html>