One thing I learnt recently which I probably should have known already is that getimagesize() returns more than just the width and height of the image. [...] However, getimagesize() also returns up to 5 more pieces of information. Interestingly, the data array is a mix of indexed elements and named elements
He gives an example of the output from the function and shows how, using data from the returned array, you can compare constants (
IMAGETYPE_PNG) to determine what the image type is. This is a better option than relying on the extension of the file as that can be easily faked.