Home  >  Article  >  Backend Development  >  What does php binary security mean?

What does php binary security mean?

WBOY
WBOYOriginal
2016-08-08 09:20:381460browse

In PHP, there is the concept of string.
In string, the size of each character is byte (compared with PHP, each character in Java is Character, which is a UTF8 character, and each character in C language can be selected at compile time).
Byte, there are ASCII code characters, such as ABC, 123, abc, and some special characters, such as carriage return, backspace, etc.
There are many special characters that cannot be displayed. In other words, there is no standard for their display methods. For example, the letter A is everywhere from code 65, and the character a is everywhere from code 97. Backspace is displayed as a symbol in some places, and in some places it actually replaces the previous character. One character is returned.
PHP is based on C, so many descriptions are compared with C. In C strings, a classic definition is to end the string with code 0. So, assuming such a string, the encodings of the three characters in it are 97, 0, and 97 respectively. Then, if there is a function equivalent to str_replace in C and you use it to replace 97 with 98, then when this function reads 0, it will be considered to be over and you will get 98,0,97. Correspondingly, str_replace in PHP is binary safe, so this 0 will not be regarded as a special end symbol, so the result is 98, 0, 98.
[Binary Security] In the PHP document, it basically means this: functions with similar functions in the C language will treat some characters specially, while this function in PHP treats all characters equally, so there is no need to worry about the impact of special characters. handle, especially don't worry about encoding 0 characters.

The above has introduced the meaning of PHP binary security, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn