Re: Sending http_get_vars array as parameter

From: Date: Thu, 04 Jan 2001 18:59:45 +0000
Subject: Re: Sending http_get_vars array as parameter
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-32707@lists.php.net to get a copy of this message
> function trimVars(&$http_vars){ > for(reset($http_vars); $key=key($http_vars);next($http_vars)) { > $this = stripslashes($http_vars[$key]); > $this = ereg_replace(">|<|\"|\||`|\\\\",'',$this); > $this = ereg_replace(" ",' ',$this); > $this = trim($this); > $$key = addslashes($this); 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. > } > } > > // Just copying the posted vars: > $http_vars1 = $HTTP_GET_VARS; > $http_vars2 = $HTTP_GET_VARS; > > > // Here I try with the function: > trimVars($http_vars1); > > // Here the same thing as plain script: > for(reset($http_vars2); $key=key($http_vars2);next($http_vars2)) { > $this = stripslashes($http_vars2[$key]); > $this = ereg_replace(">|<|\"|\||`|\\\\",'',$this); > $this = ereg_replace(" ",' ',$this); > $this = trim($this); > $$key = addslashes($this); > } > > The $http_vars2 are now stripped from the unwanted characters, > but NOT the $http_vars1 from the function. > Does somebody know why this wont work in function above? > > Best regards > Håkan > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#32707) next »