For inefficiency or not it depends on whether or there is a preponderance of text files over binary or vice versa.
Since text files are a special case of binary (in an ideal world there'd be no need for the distinction), a character-by-character search could go:
for($i=0, $n<strlen($content); $i<$n; ++$i)
if(ord($content[$i])>127)
return FILE_IS_BINARY;
return FILE_IS_TEXT;
Now if most files were generic binary, this would be a better way to go, since a non-ASCII character would tend to turn up pretty soon. (In the case of compressed binary data, one can approximate the bytes of a typical file with a uniform distribution: there are 128 ASCII bytes and 128 non-ASCII bytes, so.....)
In the case of a text file though, the above loop would look through the entire thing before realising that the FILE_IS_TEXT. This is very tedious, and is why most tests only look at the first couple hundreds bytes ("lines") or so. (Again, you can work out how unlikely a random binary file consist only of ASCII for that entire region.)*
So I figured it might be faster to skip the testing in-loop and instead accumulate at the end. I suppose I should have tested the two approaches to see if one was significantly faster than the other on a text file (obviously, the test-each-character approach would win over the accumulate-then-test on a binary file).
I tried the one-character-at-a-time approach on my copy of RFC2616 (412kš, reading the entire file, and it made the correct determination in 0.75 second. On a 419kB JPEG it had an answer in under a millisecond (not surprising: the very first byte of a JFIF-formatted image is 0xff).
The respective times using the accumulate-and-add method were 0.71s and 0.72s respectively. So ... is the difference worth it? Remember that both tests on both files were checking the entire file. If the "packed" binaries are sufficiently well-packed that they look random, then you would get very reliable results just from an initial portion.
*Of course, truly random binary files are pretty rare š Even .gz and .bz2 files have recognisable headers.