您的位置:首页 > 博客中心 > 数据库 >

mysql模糊查询特殊字符(\,%和_)处理

时间:2022-03-13 23:14

/**
* sql模糊查询特殊字符(\,%和_)处理
*
* @param string $str
* @return string
*/
public static function like_search_specialchars($str){
  return str_replace(array(‘\\‘, ‘%‘, ‘_‘), array(‘\\\\‘, ‘\\%‘, ‘\\_‘), $str);
}

热门排行

今日推荐

热门手游