导航:首页 > 编程语言 > php过滤xml特殊字符

php过滤xml特殊字符

发布时间:2022-04-25 13:38:06

php 过滤特殊字符,但不能过滤掉下划线,点,减号

特殊符号太多了,可以反向来写.
下划线,点,减号都能匹配,还有想要的都匹配就行了.
改变一下思维方式就了,如果可以帮到你,希望采纳.

㈡ 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中如何过滤所有的特殊字符

  1. 用正则匹配替换

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

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

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

实例:只匹配中文


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

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

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

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

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

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

㈦ php 获取 xml节点信息 包含特殊字符怎么处理

attributes是解析出来的,不是别人传过来的,直接用attributes()就可以获取

㈧ php过滤指定字符的函数

explode — 使用一个字符串分割另一个字符串

array explode ( string $delimiter , string $string [, int $limit ] )

此函数返回由字符串组成的数组,每个元素都是 string 的一个子串,它们被字符串 delimiter 作为边界点分割出来。

<?php
//示例1
$pizza="";
$pieces=explode("",$pizza);
echo$pieces[0];//piece1
echo$pieces[1];//piece2

//示例2
$data="foo:*:1023:1000::/home/foo:/bin/sh";
list($user,$pass,$uid,$gid,$gecos,$home,$shell)=explode(":",$data);
echo$user;//foo
echo$pass;//*

?>

㈨ php 如何过滤掉xml中的特殊字符

functionxmlentities($string,$quote_style=ENT_QUOTES)
{
static$trans;

//
//
$string=html_entity_decode($string,ENT_QUOTES);

//xmlencoding
if(!isset($trans))
{
$trans=get_html_translation_table(HTML_ENTITIES,$quote_style);
foreach(array_keys($trans)as$key)
{
$trans[$key]='&#'.ord($key).';';
}
//donttranslatethe'&'incaseitispartof&xxx;
$trans[chr(38)]='&';
}

//aftertheinitialtranslation,_do_mapstandalone'&'into'&#38;'
$str_temp=preg_replace("/&(?![A-Za-z]{0,4}w{2,3};|#[0-9]{2,3};)/u"
,"&#38;"
,strtr($string,$trans)
);
return$str_temp;
}

阅读全文

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

热点内容
泰山pdf 浏览:400
程序员与需求分析员 浏览:461
安卓手机cfg用什么软件打开 浏览:663
51单片机嵌入式系统 浏览:818
什么app可以买正品书 浏览:568
程序员对游戏的评价 浏览:465
测睡眠的app哪个好 浏览:900
塔科夫现在什么俄服服务器能玩 浏览:803
cad2012快捷命令 浏览:633
双机命令 浏览:884
android默认语言设置在哪 浏览:783
淑女鞋命令 浏览:387
相册怎么样加密码下载 浏览:881
python做前端开发 浏览:892
网吧怎么租服务器 浏览:276
ansys画圆命令流 浏览:774
腾讯云盘服务器地址 浏览:762
无损压缩可以压文档嘛 浏览:115
人工智能编译视频 浏览:525
什么新闻app比较真实 浏览:348