SV: [PHP] Sending http_get_vars array as parameter
| From: | H�kan Askengren | Date: | Thu, 04 Jan 2001 23:28:17 +0000 |
| Subject: | SV: [PHP] Sending http_get_vars array as parameter | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-32767@lists.php.net to get a copy of this message | ||
Thank you very much Richard
Below is the modified function, free to use.
Note 1: The global is used for the $$key and not the $key
(To set the actual variable outside the function).
Note 2: The $http_vars[$key] is also set.
(To set the $HTTP_GET_VARS)
function trimVars(&$http_vars){
for(reset($http_vars); $key=key($http_vars);next($http_vars)) {
$tmpVar = stripslashes($http_vars[$key]);
$tmpVar = ereg_replace(">|<|\"|\||`|\\\\",'',$tmpVar);
$tmpVar = ereg_replace(" ",' ',$tmpVar);
$tmpVar = trim($tmpVar);
$http_vars[$key]=addslashes($tmpVar);
global $$key;
$$key = $http_vars[$key];
}
}
"Richard Lynch" <richard@zend.com> skrev i
diskussionsgruppsmeddelandet:020e01c07690$b352f360$64aa8ed8@142.170.100...
>
> Unless $key is global, changing $$key here is ineffectual.
> Add global $key; before this line.
>
> Oh yeah: I'd use something other than '$this' as a variable name -- $this
> has special meaning in PHP OO classes, and you're likely to confuse
yourself
> or other programmers using it elsewhere.
>