php去除非法字符的方法:可以利用php中的str_replace函数来去除字符串中的非法字符,如【$str = str_replace('\\','',$str);】。
本文操作环境:windows10系统、php 7.3、thinkpad t480电脑。
函数介绍:
str_replace() 函数替换字符串中的一些字符(区分大小写)。
语法:
1 |
|
参数介绍:
find 必需。规定要查找的值。
replace 必需。规定替换 find 中的值的值。
string 必需。规定被搜索的字符串。
count 可选。一个变量,对替换数进行计数。
实现代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
相关推荐:php教程
The above is the detailed content of How to remove illegal characters in php. For more information, please follow other related articles on the PHP Chinese website!