PHP 对客户端输入进行输入转义
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | // 对 用户提交的数据 ' " \ 进行转义 if ( get_magic_quotes_gpc() ) { function del_magic_quotes( $value ) { $value = is_array ( $value ) ? array_map ( 'del_magic_quotes' , $value ) : stripslashes ( $value ); return $value ; } $_POST = del_magic_quotes( $_POST ); $_GET = del_magic_quotes( $_GET ); $_COOKIE = del_magic_quotes( $_COOKIE ); $_REQUEST = del_magic_quotes( $_REQUEST ); } function add_magic_quotes( $array ) { foreach ( ( array ) $array as $k => $v ) { if ( is_array ( $v ) ) { $array [ $k ] = add_magic_quotes( $v ); } else { $array [ $k ] = addslashes ( $v ); } } return $array ; } $_GET = add_magic_quotes( $_GET ); $_POST = add_magic_quotes( $_POST ); $_COOKIE = add_magic_quotes( $_COOKIE ); $_REQUEST = add_magic_quotes( $_REQUEST ); |
欢迎转载,转载请注明:转载自[ http://www.cnblogs.com/zjfree/ ]
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步