php3-list | 199901
Date: 01/09/99
- Next message: Christopher Curtis: "Re: [PHP3] FORM image pressed"
- Previous message: Rasmus Lerdorf: "Re: [PHP3] Variable variables as class names"
- In reply to: Rasmus Lerdorf: "Re: [PHP3] $HTTP_POST_VARS"
- Next in thread: Rasmus Lerdorf: "Re: [PHP3] $HTTP_POST_VARS"
- Reply: Rasmus Lerdorf: "Re: [PHP3] $HTTP_POST_VARS"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 8 Jan 1999, Rasmus Lerdorf wrote:
> > array_walk($HTTP_POST_VARS,'filter');
> >
> > The values of changed variables work only when called as:
> > $HTTP_POST_VARS[var_new_1];
> >
> > but incorrect when called directly as $var_new_1
> >
> > WHY?
>
> Because you are in a function and trying to access a global variable.
> Stick a: "global $var_new_1" at the top of the function and it will work.
Rasmus, the following is what I did.
---
// Filter the incoming data (strip excessive spaces & remove HTML tags)
Function filter ($in_string) {
global $HTTP_POST_VARS; // It looks weird to put this variale as
// global here, but put "$in_string" global
// generates errors
$in_string = trim(ereg_replace("(\n\r)+","\n\r",
ereg_replace(" +"," ",
ereg_replace("<[^>]*>","",$in_string))));
}
array_walk($HTTP_POST_VARS,'filter');
echo $HTTP_POST_VARS[f_name]; // with excessive spaces/newlines/HTML tags
// stripped
echo $f_name; // this remains unchanged
---
1) WHY? What did I do wrong in this case?
2) In fact is there a better way to accomplish what I intended?
i.e. To remove all spaces from the beginning and end of the string,
to condense excessive spaces " +" to single space " ", and
to strip all HTML tags
for all user inputs
Thanks a lot again!
Regards,
harmony
> -Rasmus
>
>
> --
> PHP 3 Mailing List http://www.php.net/
> To unsubscribe send an empty message to php3-unsubscribe <email protected>
> To subscribe to the digest list: php3-digest-subscribe <email protected>
> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3
> List administrator: zeev <email protected>
>
>
>
--
PHP 3 Mailing List http://www.php.net/
To unsubscribe send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest list: php3-digest-subscribe <email protected>
For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3
List administrator: zeev <email protected>
- Next message: Christopher Curtis: "Re: [PHP3] FORM image pressed"
- Previous message: Rasmus Lerdorf: "Re: [PHP3] Variable variables as class names"
- In reply to: Rasmus Lerdorf: "Re: [PHP3] $HTTP_POST_VARS"
- Next in thread: Rasmus Lerdorf: "Re: [PHP3] $HTTP_POST_VARS"
- Reply: Rasmus Lerdorf: "Re: [PHP3] $HTTP_POST_VARS"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

