Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen:
Determining the image type of a file
Mar 04, 2016 @ 11:08:14

In his latest post Rob Allen shows a handy way, making use of the http://php.net/getimagesize function, to determine the image type of a file based on header information returned.

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_JPEG, IMAGETYPE_GIF, 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.

tagged: image type determine tutorial getimagesize constant

Link: https://akrabat.com/determining-the-image-type-of-a-file-with-getimagesize/

Matt Kalinowski's Blog:
Determine Browser Speed with PHP
May 31, 2006 @ 05:52:52

On Matt Kalinowski's blog, there's a quick post with some code to help you test just how fast your user's browser speed is as they hit your site.

So, you have a site that offers both an enhanced and standard style page. However, you realize that not every web user is going to know if they would be best suited for either version. Therefor, this speed test will allow you to determine their speed. This could also be used in other situations as well, but the one stated above is the one I found most appropriate.

Basically, the script works with the microtime functionality in PHP to do some speed tests for the amount of data given divided by how long it takes that data to get out to the user.

tagged: determine browser speed microtime divide determine browser speed microtime divide

Link:

Matt Kalinowski's Blog:
Determine Browser Speed with PHP
May 31, 2006 @ 05:52:52

On Matt Kalinowski's blog, there's a quick post with some code to help you test just how fast your user's browser speed is as they hit your site.

So, you have a site that offers both an enhanced and standard style page. However, you realize that not every web user is going to know if they would be best suited for either version. Therefor, this speed test will allow you to determine their speed. This could also be used in other situations as well, but the one stated above is the one I found most appropriate.

Basically, the script works with the microtime functionality in PHP to do some speed tests for the amount of data given divided by how long it takes that data to get out to the user.

tagged: determine browser speed microtime divide determine browser speed microtime divide

Link: