当前位置:首页 » 编程语言 » php过滤敏感词

php过滤敏感词

发布时间: 2022-09-13 14:27:00

A. php提交自动过滤掉input框内的指定字符,怎么写呢

tr_replace() 函数使用一个字符串替换字符串中的另一些字符。
语法
str_replace(find,replace,string,count)

参数
描述

find 必需。规定要查找的值。
replace 必需。规定替换 find 中的值的值。
string 必需。规定被搜索的字符串。
count 可选。一个变量,对替换数进行计数。
提示和注释
注释:该函数对大小写敏感。请使用 str_ireplace() 执行对大小写不敏感的搜索。
注释:该函数是二进制安全的。
例子
例子 1
<?php
echo str_replace("world","John","Hello world!");
?>

输出:
Hello John!

例子 2
在本例中,我们将演示带有数组和 count 变量的 str_replace() 函数:
<?php
$arr = array("blue","red","green","yellow");
print_r(str_replace("red","pink",$arr,$i));
echo "Replacements: $i";
?>

输出:
Array
(
[0] => blue
[1] => pink
[2] => green
[3] => yellow
)
Replacements: 1

例子 3
<?php
$find = array("Hello","world");
$replace = array("B");
$arr = array("Hello","world","!");
print_r(str_replace($find,$replace,$arr));
?>

输出:
Array
(
[0] => B
[1] =>
[2] => !
)

B. PHP 如何过滤特殊字符 如 ◆ )- : 、 、!! / 等

PHP 中的 preg_replace() 函数可以实现

实例:只匹配中文


<?php
$str="php)!!编程";
echopreg_replace("/[^x{4e00}-x{9fa5}]/iu",'',$str);
?>

C. php怎样过滤非法字符防止sql注入

htmlspecialchars($_POST['字段']),用这个函数就可以将一些特殊字符进行过滤转义。你可以去看看这个函数的说明。

D. PHP字符串中特殊符号的过滤方法介绍

本篇文章主要是对PHP字符串中特殊符号的过滤方法进行了详细的介绍,需要的朋友可以过来参考下,希望对大家有所帮助
有时候我们会遇到过滤字符串中特殊字符的问题,本文提供了一个处理特殊字符串的方法,可能有遗漏,如果读者发现了可以
代码如下:
function
strFilter($str){

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

return
trim($str);
}

E. php 如何过滤特殊字符,如 ◆ )- : 、 、!! /   等

可以用 str_replace() 函数统一替换,如:
$string = "测试◆例子♂ 在此 !";
$replace = array('◆','♂',')','=','+','$','¥','-','、','、',':',';','!','!','/');
$string = str_replace($replace, '', $string);
echo $string;

F. php 小问题大侠们.

echo "<a href='#' onclick=\”window.open('dongtai/login.php','用户注册','width=310 height=300')\"";
你要做什么?

G. php 如何过滤 单引号 双引号 $ < > 等N种特殊符号谢谢

我给楼主吧- - 首先是过滤html,将html编码转换为实体编码 /**
* 将特殊字符转成 HTML 格式。
* @param string $value - 字符串或者数组
* @return array
*/
public static function htmlspecialchars($value) {
return is_array($value) ? array_map('k::htmlspecialchars', $value) :
preg_replace('/&((#(\d{3,5}|x[a-fA-F0-9]{4})|[a-zA-Z][a-z0-9]{2,5});)/', '&\\1',
str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $value));
} 还有一个去除html编码的,可以直接用php的函数strip_tags()

H. PHP 如何过滤特殊字符 如◆

可以用 str_replace() 函数统一替换,如:
$string = "测试◆例子♂ 在此 !";
$replace = array('◆','♂',')','=','+','$','¥','-','、','、',':',';','!','!','/');
$string = str_replace($replace, '', $string);
echo $string;

I. 谁知道PHP中正则是神马意思

主要过滤敏感词,替换文本中的字符,验证电话号码,邮件地址等一些数据。有点类似一般文本编辑器中的查找替换。

J. php怎样过滤掉特殊字符啊 ☺

过滤掉特殊字符,可以考虑使用字符串替换的方法,在php中替换字符效率最高也是最简单字符替换函数str_replace函数。

使用方法:str_replace(find,replace,string,count)

参数说明:

find 必需。规定要查找的值。

replace 必需。规定替换 find 中的值的值。

string 必需。规定被搜索的字符串。

count 可选。一个变量,对替换数进行计数。

实例:

str_replace("iwind","kiki","iloveiwind,iwindsaid");

将输出 "i love kiki, kiki said"

当然你也可以采取正则替换的方法,该函数是preg_replace

热点内容
内存和缓存的区别 发布:2025-05-16 06:42:42 浏览:187
配电车编程 发布:2025-05-16 06:41:22 浏览:369
安卓微信浅色模式怎么恢复 发布:2025-05-16 06:27:53 浏览:240
美嘉算法口诀 发布:2025-05-16 06:03:15 浏览:953
c程序编译连接 发布:2025-05-16 06:02:36 浏览:965
脚本魔兽 发布:2025-05-16 06:01:52 浏览:331
文件夹python 发布:2025-05-16 06:01:43 浏览:627
电脑我的世界服务器游戏币 发布:2025-05-16 05:27:25 浏览:491
索尼手机为什么不能用安卓10 发布:2025-05-16 05:18:46 浏览:784
蔚来es6选择哪些配置实用 发布:2025-05-16 05:18:05 浏览:130