PHP determines the mime format of an image. a JPEG (JFIF) file starts from 6th bytes and reads 5 bytes consecutively. The value is 0x4A46494600,
However, I always return false for my judgment!
$ Bytes = file_get_contents('1.jpg ', null, null, 5, 5); echo $ bytes = "\ x4A \ x46 \ x49 \ x46 \ x00 "; // Here, falseecho "\ x4A \ x46 \ x49 \ x46 \ x00" is always returned; // JFIF and an invisible control character \ 0 is displayed
If strpos is used to find out whether these five bytes contain JFIF, it is acceptable, but I want to use = to judge whether the = operator does not work for this operation?
Solution!
Reply to discussion (solution)
$ Bytes = file_get_contents('1.jpg ', null, null, 6, 5 );
Who told you it was the sixth?
Echo $ bytes;
You don't know.
$ Bytes = file_get_contents('1.jpg ', null, null, 6, 5 );
Who told you it was the sixth?
Echo $ bytes;
You don't know.
Er, I am wrong...
Thank you!