This article introduces a common php method for getting variable values globally. For more information, see.
The Code is as follows: |
Copy code |
<? Function my_addslashes ($ string, $ force = 0 ){ ! Defined ('Magic _ QUOTES_GPC ') & define ('Magic _ QUOTES_GPC', get_magic_quotes_gpc ()); If (! MAGIC_QUOTES_GPC | $ force ){ If (is_array ($ string )){ Foreach ($ string as $ key => $ val ){ $ String [$ key] = my_addslashes ($ val, $ force ); } } Else { $ String = addslashes ($ string ); } } Return $ string; } Foreach (array ('_ cookies',' _ Post', '_ get') as $ _ request ){ Foreach ($ _ request as $ _ key => $ _ value ){ $ _ Key {0 }! = '_' & $ _ Key = my_addslashes ($ _ value ); } } Echo $ urls; ?> |
Here, we use foreach to traverse the variables to determine whether the cookie, post, and get methods are used. In this way, when I use my_addslashes directly, the difference is that the values from post, get, and cookie are automatically different.