Home  >  Article  >  Backend Development  >  Regarding the problem of processing multiple consecutive backslashes in the PHP function stripslashes

Regarding the problem of processing multiple consecutive backslashes in the PHP function stripslashes

WBOY
WBOYOriginal
2016-07-29 08:57:251547browse

php function: stripslashes()

Remove backslashes, function prototype string stripslashes (string $str), returns a string with escaped backslashes removed (' converted to ', etc.).

It is mentioned in the PHP official website that it returns a string with escaped backslashes removed (' converted to ', etc.). Double backslash (\) is converted into a single backslash (). In fact, this is inaccurate. My test should be the following result:

In the case of multiple consecutive backslashes, use it to escape There is no guarantee that there will be no backslashes in the return characters. For example, if there are three consecutive backslashes, one return will be retained. , after testing, the rule for removing backslashes by this function is: if there are two consecutive backslashes or less, all are removed; if there are more than two, subtract 2 and divide by 4, and then round to the nearest integer, such as 7 consecutive backslashes After being processed by it, the bars are: ceil((7-2)/4)=2, so in actual application, you can replace more than 3 consecutive backslashes with 3 and then use this function. Note that this issue is not mentioned on the official PHP website.

This blog is original, please indicate the source for reprinting: http://blog.csdn.net/u011474028

The above introduces the problem of processing multiple consecutive backslashes by the PHP function stripslashes, including the relevant aspects. 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