|
1樓 220.221.122.*
2010-12-11 14:16
看来php获取ajaxcode编码的参数,用的函数太多了,太混乱了。干脆这样:
//ajax获得参数简写函数 function reajax($name,$code=2,$type=false){ //$code:0=不编码,1=htmlspecialchars,2=mysql_real_escape_string //$type:false=post,true=get if ($type){ $b=$_GET[$name]; }else{ $b=$_POST[$name]; //默认 } $b=trim(read_utf8_uns($b)); switch ($code){ case 1: $b=htmlspecialchars($b); break; case 2: $b=mysql_real_escape_string($b); //默认 break; } return $b; }
|
|
2樓 220.221.122.*
2010-12-11 14:17
mysql_real_escape_string(trim(read_utf8_uns($_POST['b'])))
就可以简写为reajax('b');
|
|
3樓 220.221.122.*
2010-12-11 14:18
还差个unajaxcode……
|
|
4樓 220.221.122.*
2010-12-11 14:19
//ajax获得参数简写函数 function reajax($name,$code=2,$type=false,$nounajaxcode){ //$code:0=不编码,1=htmlspecialchars,2=mysql_real_escape_string //$type:false=post,true=get //$nounajaxcode:是否不还原ajaxcode编码 if ($type){ $b=$_GET[$name]; }else{ $b=$_POST[$name]; //默认 } $b=trim(read_utf8_uns($b)); if (!$nounajaxcode) $b=unajaxcode($b); switch ($code){ case 1: $b=htmlspecialchars($b); break; case 2: $b=mysql_real_escape_string($b); //默认 break; } return $b; }
|
|
5樓 220.221.122.*
2010-12-11 14:22
//ajax获得参数简写函数 function reajax($name='i',$code=2,$type=false,$nounajaxcode){ //$code:0=不编码,1=htmlspecialchars,2=mysql_real_escape_string //$type:false=post,true=get //$nounajaxcode:是否不还原ajaxcode编码 if ($type){ $b=$_GET[$name]; }else{ $b=$_POST[$name]; //默认 } $b=trim(read_utf8_uns($b)); if (!$nounajaxcode) $b=unajaxcode($b); switch ($code){ case 1: $b=htmlspecialchars($b); break; case 2: $b=mysql_real_escape_string($b); //默认 break; } return $b; }
现在这三个参数都是可选的。
reajax()≌mysql_real_escape_string(unajaxcode(trim(read_utf8_uns($_POST['i']))))
|