Some of the methods in PHP are described as "binary security." What does that mean?
Reply content:
Some of the methods in PHP are described as "binary security." What does that mean?
This means that the function can operate normally when the parameters of the function include binary data.
Strlen, for example, does not stop here when there is a/T in the input data. So it can be said that binary security.
I also see this in the Redis database introduction. I think the binary security should be said:
Only the binary strings are concerned, not the specific format. Only strict binary data access is required. No attempt has been made to parse the data in some form.
Sometimes opening a file in the wrong format can cause irreversible damage to the file. Binary security means that this damage is avoided.
For example, function strcoll, which is non-binary security. The strcmp is binary safe.
The difference between them is:
$string1 = "Hello";$string2 = "Hello\x00Hello";echo strcoll($string1, $string2); // 返回0, 由于是非二进制安全,误判为相等echo strcmp($string1, $string2); // 返回负数