What is the best way to determine the dimensions of an image in PHP when the image is uploaded through a form?

When an image is uploaded through a form in PHP, you can use the `getimagesize()` function to determine the dimensions of the image. This function returns an array with the image width and height. By using this function, you can easily retrieve the dimensions of the uploaded image and perform any necessary validation or processing based on the dimensions.

// Check if a file was uploaded
if(isset($_FILES['image'])){
    // Get the dimensions of the uploaded image
    $image_info = getimagesize($_FILES['image']['tmp_name']);
    
    // Extract width and height from the image info array
    $width = $image_info[0];
    $height = $image_info[1];
    
    // Output the dimensions of the uploaded image
    echo "Image width: " . $width . "px<br>";
    echo "Image height: " . $height . "px";
}