3v4l.org

run code in 300+ PHP versions simultaneously
<?php $finfo = new finfo(FILEINFO_MIME_TYPE); $postMimeType = $finfo->buffer(file_get_contents('http://img1.wikia.nocookie.net/__cb20130830065058/cardfight/images/7/7a/Smiley-face-1600x1200-wallpaper-775678.jpg')); // If the URL has the file extension included, this will find it $fileExtension = pathinfo('http://img1.wikia.nocookie.net/__cb20130830065058/cardfight/images/7/7a/Smiley-face-1600x1200-wallpaper-775678.jpg', PATHINFO_EXTENSION); // Otherwise, get file extension from the MIME type // This is necessary for image thumbnails to display correctly in the WordPress dashboard media section if ($fileExtension === '') { $fileExtension = basename($postMimeType); $filename = $filename . '.' . $fileExtension; } var_dump($fileExtension);

preferences:
36.96 ms | 402 KiB | 5 Q