对数据库字符串定义

<?php
/*
* 对数据字符串进行转义
*/
function check_str($string,$isurl=false){

$string=preg_replace('/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]/','',$string);
$string=str_replace(array("\0","%00","\r"),'',$string);

empty($isurl) && $string=preg_replace("/&(?!(#[0-9]+|[a-z]+);)/si",'&',$string);
$string = str_replace(array("%3C",'<'),'<',$string);
$string = str_replace(array("%3E",'>'),'>',$string);
// $string = str_replace(array('"',"'","\t",''),array('"',''',' ',' '),$string);
return trim($string);

}
//相关连接:
//http://www.cnblogs.com/my37gs/archive/2011/12/07/2278697.html

posted @ 2012-12-20 08:59  sgsheg  阅读(224)  评论(0编辑  收藏  举报