Home >php教程 >php手册 >PHP的一个字符过滤函数

PHP的一个字符过滤函数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-21 09:05:561211browse

函数

function safe_convert($string$html=0) { //Words Filter
    
if ($html==0
) {
        
$string=htmlspecialchars($stringENT_QUOTES
);
        
$string=str_replace(",",$string
);
        
$string=str_replace(">",">",$string
);
        
$string=str_replace("\\"'\'$string
);
    } else {
        
$string=addslashes($string
);
        
$string=str_replace("\\\\"'\'$string
);
    }
    
$string=str_replace("\r","
"
,$string
);
    
$string=str_replace("\n","",$string
);
    
$string=str_replace("\t","  ",$string
);
    
$string=str_replace("  ","  ",$string
);
    
$string=str_replace('|''|'$string
);
    
$string=str_replace("`","`",$string
);
    
$string=str_replace("\","\",$string
);
    return 
$string
;



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn