It is not clear what exactly you are doing and why your php script has to recognize pdf.
If you are loading the file by your php application - you can check content type header of the file, which contains file type information along with the extension. You can use http://php.net/manual/en/book.curl.php library for it.
If you want to let users download the file on your site - you have to set correct content type like this:
header('Content-Type: application/pdf');
Now the browser will know that the file you are serving is pdf even without extension.
Update
Eventually it turned out that the site with pdf files just required some cookies, as described below.