Binary security Functions (Binary-safe function) are functions or operations that do not change the contents of a file on a binary file. This ensures that files are not damaged by certain operations. Binary data is encoded in the form of a string of 0 and 1. Most programs give different format codes to specific bit strings, so when a user reads a binary file using a program, the file is interpreted according to the rules of the program. If the format encoding used by this program is the same as the format in which the file is written, the file can be read normally, otherwise the format code of the file will be appended with some meaningless symbols, which may cause the file corruption. If the most serious situation occurs, such an operation will cause your data to be permanently lost due to damage. So you should keep important files on a read-only storage medium, such as a disc.
In PHP, there is the concept of string.
In string, the size of each character is byte (compared to PHP, each character in Java is character, which is the UTF8 character, and each character in the C language can be selected at compile time).
In byte, there are ASCII code characters, such as ABC,123,ABC, and some special characters, such as carriage return, backspace, and so on.
Many of the special characters are not displayed. Or, they do not display the standard, for example, code 65 to where the letter A, code 97 to where the character a, backspace in some places to display a symbol, in some places will really return the previous character.
PHP is based on C, so many of the descriptions are in the C comparison. In the C string, a classic definition is to encode 0 as the end of a string. So, suppose such a string, where the 3-character encoding is 97,0,97. So, if there is str_replace equivalent function in C, use it to change 97 to 98, then this function reads to 0, it is considered to be finished, it will get 98,0,97. corresponding to it, PHP str_replace is binary security, then the 0 will not be considered a special end symbol, so the result is 98,0,98.
"Binary security" in the PHP document, basically is the meaning of: C language functions similar to the function will be special processing of some characters, and PHP this function for all characters equal, do not worry about special characters affect processing, especially do not worry about encoding 0 characters.
Binary Security in PHP