How can PHP be used to dynamically adjust the size of images displayed in a popup window?

To dynamically adjust the size of images displayed in a popup window using PHP, you can pass the desired width and height as parameters in the URL when opening the popup window. Then, in the popup window, you can retrieve these parameters using PHP and use them to set the size of the image.

// In the main page where the popup window is opened
$imageWidth = 500; // Set the desired width of the image
$imageHeight = 300; // Set the desired height of the image
echo "<a href='popup.php?width=$imageWidth&height=$imageHeight' target='_blank'>Open Popup</a>";

// In the popup.php file
$imageWidth = isset($_GET['width']) ? $_GET['width'] : 400; // Default width is 400
$imageHeight = isset($_GET['height']) ? $_GET['height'] : 300; // Default height is 300
echo "<img src='image.jpg' width='$imageWidth' height='$imageHeight'>";