"\\\\", '_' => '_', '%' => '%"/> "\\\\", '_' => '_', '%' => '%">

Home  >  Article  >  Backend Development  >  php-对mysql like 内容进行转义的函数 的疑问?

php-对mysql like 内容进行转义的函数 的疑问?

WBOY
WBOYOriginal
2016-06-02 11:33:421462browse

php

<code> /** * 对 MYSQL LIKE 的内容进行转义 * * @access      public * @param       string      string  内容 * @return      string */function mysql_like_quote($str){    return strtr($str, array("\\\\" => "\\\\\\\\", '_' => '\_', '%' => '\%', "\'" => "\\\\\'"));}</code>

函数里为什么要把四个反斜杠转换成八个反斜杠? 把一个反斜杠加单引号转成五个反斜杠加单引号?

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