Linux 拨号vps windows公众号手机端

php如何处理非法字符串

lewis 6年前 (2019-03-23) 阅读数 17 #程序编程
文章标签 PHP字符串

在php中使用str_replace()函数对非法字符串进行处理,具体方法如下:

str_replace()函数作用:

php中str_replace()函数的作用是用于替换字符串中的字符。

str_replace()函数语法:

str_replace(find,replace,string)

参数:

find:需要处理的非法字符。

replace:替换非法字符的值。

string:指定字符串。

str_replace()函数使用方法:

例:去除字符串中的@、$、*非法字符

function remove_chars($str){

$str = str_replace('@','',$str);

$str = str_replace('$','',$str);

$str = str_replace('*','',$str);

return $str;

}

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门