"\\\\", '_' => '_', '%' => '%"/> "\\\\", '_' => '_', '%' => '%">
Home > Backend Development > PHP Tutorial > php-对mysql like 内容进行转义的函数 的疑问?

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

WBOY
Release: 2016-06-02 11:33:42
Original
1556 people have browsed it

php

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

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template