How can PHP be integrated with CSS to customize the appearance of images on a webpage?

To customize the appearance of images on a webpage using PHP and CSS, you can dynamically generate the CSS styles for each image based on certain criteria or attributes. This can be achieved by embedding PHP code within the HTML markup to output inline CSS styles specific to each image.

<?php
// PHP code to generate CSS styles for images
$image1_style = "width: 200px; border: 2px solid red;";
$image2_style = "width: 150px; border: 1px dashed blue;";
?>

<!DOCTYPE html>
<html>
<head>
    <style>
        .image1 {
            <?php echo $image1_style; ?>
        }

        .image2 {
            <?php echo $image2_style; ?>
        }
    </style>
</head>
<body>
    <img src="image1.jpg" class="image1" />
    <img src="image2.jpg" class="image2" />
</body>
</html>