note 69083 added to ref.pdf
| From: | brendandonhue at comcast dot net | Date: | Tue, 22 Aug 2006 15:35:05 +0000 |
| Subject: | note 69083 added to ref.pdf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116173@lists.php.net to get a copy of this message | ||
Here is a function to test whether a file is a PDF without using any external library.
<?php
function is_pdf($filename) {
define('PDF_MAGIC', "\\x25\\x50\\x44\\x46\\x2D");
return (file_get_contents($filename, false, null, 0, strlen(PDF_MAGIC)) === PDF_MAGIC) ? true :
false;
}
?>
It's not checking if the whole file is valid, just if the correct header is present at the
beginning of the file.
----
Server IP: 216.194.113.175
Probable Submitter: 68.43.121.42
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/ref.pdf.php
Edit -- https://master.php.net/note/edit/69083
Del: integrated -- https://master.php.net/note/delete/69083/integrated
Del: useless -- https://master.php.net/note/delete/69083/useless
Del: bad code -- https://master.php.net/note/delete/69083/bad+code
Del: spam -- https://master.php.net/note/delete/69083/spam
Del: non-english -- https://master.php.net/note/delete/69083/non-english
Del: in docs -- https://master.php.net/note/delete/69083/in+docs
Del: other reasons-- https://master.php.net/note/delete/69083
Reject -- https://master.php.net/note/reject/69083
Search -- https://master.php.net/manage/user-notes.php