Are there best practices for adjusting image size to fit different screen resolutions in PHP?

When adjusting image size to fit different screen resolutions in PHP, it is recommended to use CSS media queries to set the image size based on the screen width. By using responsive design techniques, you can ensure that images are displayed appropriately on various devices and screen sizes.

<?php
echo '<style>';
echo '@media screen and (max-width: 600px) {';
echo '  img { width: 100%; }';
echo '}';
echo '</style>';
?>