导航:首页 > 净水问答 > php怎么过滤特殊字符

php怎么过滤特殊字符

发布时间:2022-09-03 07:27:32

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

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

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

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

㈢ PHP怎样过滤中文状态下特殊字符(比如标点符号)

functionfilterGBK_SpecialChars($str)
{
$str=urlencode($str);//将关键字编码
//下面的必须写在一行,不可换行截断
$str=preg_replace("/(%7E|%60|%21|%40|%23|%24|%25|%5E|%26|%27|
%2A|%28|%29|%2B|%7C|%5C|%3D|-|_|%5B|%5D|%7D|%7B|%3B|%22|%3A|
%3F|%3E|%3C|%2C|.|%2F|%A3%BF|%A1%B7|%A1%B6|%A1%A2|%A1%A3|%A3%AC|
%7D|%A1%B0|%A3%BA|%A3%BB|%A1%AE|%A1%AF|%A1%B1|%A3%FC|%A3%BD|%A1%AA|
%A3%A9|%A3%A8|%A1%AD|%A3%A4|%A1%A4|%A3%A1|%A1%AB|%A3%FB|%A3%FD|%A1%BE|
%A1%BF|)+/",'',$str);
$str=urldecode($str);//将过滤后的关键字解码
return$str;
}
$str='广~·@#¥%……&*()——+|-=、{}【】:;“”‘’~“《》,。?、州;?海【,鲜。餐“”】(,厅)';
echofilterGBK_SpecialChars($str);

㈣ PHP 如何过滤特殊字符 如◆

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

㈤ PHP如何过滤★等特殊符号

我的程序是这样编写的,相信你一看就懂:

if(preg_match("/[ '.,:;*?~`!@#$%^&+=)(<>{}]|回\]|\[|\/|\\\|\"|\|/",$user)){
echo '不要在名字里面整些特答殊符号,请只使用字母、数字和汉字,当然要你的浏览器要选简体中文GB2312哟,千万不要选繁体、中文HZ等。返回修改后,再来,我等你哟!';
exit();
}

㈥ php中如何过滤所有的特殊字符

  1. 用正则匹配替换

  2. 用函数str_replace一个一个替换

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

^

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

实例:只匹配中文


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

㈧ 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);
}

㈨ 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()

阅读全文

与php怎么过滤特殊字符相关的资料

热点内容
饮水机回气孔怎么换 浏览:814
污水管道满了怎么办 浏览:117
内源污水是什么 浏览:189
3m过滤器说明手册 浏览:813
佛山工业污水检测 浏览:248
洗照片的废水含银多少 浏览:66
轻钢树脂瓦斜屋顶 浏览:192
鞭毛虫为什么能净化污水 浏览:666
大学废水水质 浏览:605
疏水性除菌过滤器 浏览:777
饮水机烫小孩怎么处理 浏览:784
贝壳工艺品清洗废水 浏览:945
y柚子皮能去除水垢 浏览:750
静电式油雾净化器怎么修 浏览:486
分辨蒸馏水与澄清石灰水 浏览:449
污水井底应比排出管低多少 浏览:493
怎么去掉电热水壶里面的水垢 浏览:401
净水机电量多少合适 浏览:547
喷淋废水直接排放 浏览:961
水处理树脂多长时间再生 浏览:926