Phpaddslashes uses recursion to reference strings using backslash. Implementation Code: Copy the code as follows :? Phpfunctionaddslashes_deep ($ value) {the most classic recursion in history. how does one row get returnis_array ($ value )? Array_map (addslashes_deep,
Implementation code:
The code is as follows:
Function addslashes_deep ($ value)
{
// The most classic recursion in history, done in one row
Return is_array ($ value )? Array_map ('addslashes _ deep ', $ value): addslashes ($ value );
}
// Test data
$ _ POST ['str'] = "'hanglor 'is \ a boy> '";
$ _ GET ['str1'] = 'hanglor "is \ a boy> ';
Echo 'the current get_magic_quotes_gpc is '. get_magic_quotes_gpc ();
Echo"
";
// Determine whether get_magic_quotes_gpc is enabled.
If (! Get_magic_quotes_gpc ()){
$ _ POST = addslashes_deep ($ _ POST );
$ _ GET = addslashes_deep ($ _ GET );
$ _ COOKIE = addslashes_deep ($ _ COOKIE );
}
// Print the result
Var_dump ($ _ POST );
Echo"
";
Var_dump ($ _ GET );
?>
Print result:
The current get_magic_quotes_gpc value is 0.
Array (1) {["STR"] => string (30) "\ 'hanglor \ 'is \ a boy> \'"}
Array (1) {["STR1"] => string (26) "fanglor \" is \ a boy> "}
The pipeline code is as follows :? Php function addslashes_deep ($ value) {// The most classic recursion in history. can return is_array ($ value) be implemented in one row )? Array_map ('addslashes _ deep ',...