<?php $filename = 'path/to/image'; $handle = fopen($filename, 'rb'); $header = fread($handle, 8); fclose($handle); if ($header === "\x89PNG\x0d\x0a\x1a\x0a") { echo 'PNG'; } elseif (substr($header, 0, 2) === "\xff\xd8") { echo 'JPEG'; } elseif (preg_match('/\AGIF8[79]a/', $header)) { echo 'GIF'; } else { echo 'something else' } $ git clone https://yourname@github.com/yourproject/yourrepo $ git sub
![make world](https://cdn-ak-scissors.b.st-hatena.com/image/square/06a15c64ba0ceec233d86d71001ebb29a9dcbf5d/height=288;version=1;width=512/https%3A%2F%2Fcdn.blog.st-hatena.com%2Fimages%2Ftheme%2Fog-image-1500.png)