p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: RES: RE: switch problem


Message #1 by "Rodrigo Penloski - Som Livre.com" <Rodrigo@s...> on Tue, 29 Oct 2002 14:20:18 -0300
Ok, i'll get with $HTTP_GET_VARS['pag'], but how do I send to it??

-----Mensagem original-----
De: David Scott-Bigsby [mailto:DScott-Bigsby@P...]
Enviada em: ter=E7a-feira, 29 de outubro de 2002 14:03
Para: beginning php
Assunto: [beginning_php] RE: switch problem


Rodrigo,

> The variable $pag comes from another page through the URL:
>
> localhost/mytests/switch.php?pag=3Dname.

You're doing it the "old way".

PHP used to create variables for you based on the names in name=3Dvalue
pairs, but, by default, this is turned off in more recent versions of
PHP. You can turn this behaviour back on, although it's not recommended.

You can get the query string values through the global array
$HTTP_GET_VARS, e.g.,

	switch ($HTTP_GET_VARS['pag'])
	...

There are other global arrays for the same purpose -- I think
$HTTP_GET_VARS is deprecated in favour of $HTTP_GET or somesuch. (By not
on my box -- we haven't upgraded yet.)

dsb

***************************************       
David Scott-Bigsby
Product Manager, Web Site and PEDN

PureEdge Solutions
The Leader in Secure XML e-Forms

v:250-708-8145  f:250-708-8010
1-888-517-2675   www.PureEdge.com
***************************************


> -----Original Message-----
> From: Rodrigo Penloski - Som Livre.com
> [mailto:Rodrigo@s...]
> Sent: Tuesday, October 29, 2002 6:43 AM
> To: beginning php
> Subject: [beginning_php] switch problem
>
>
> I have this code:
>
> <?
> switch ($pag) {
> 	case 'name':
> 	print "Joseph";
> 	break;
> =09
> 	case 'mail':
> 	print "joseph@s...";
> 	break;
> =09
> 	case 'age':
> 	print "21";
> 	break;
> =09
> 	default:
> 	print "default";
> }
> ?>
>
> The variable $pag comes from another page through the URL:
>
> localhost/mytests/switch.php?pag=3Dname.
>
> Well the problem is, it doesn't work..
>
> What am I doing wrong?
>
> Thanx in advance;
>
> Rodrigo
>
>

Message #2 by "David Scott-Bigsby" <DScott-Bigsby@P...> on Tue, 29 Oct 2002 09:33:42 -0800
> Ok, i'll get with $HTTP_GET_VARS['pag'], but how do I send to it??

Oh, PHP automatically creates the array and an item (e.g., 'pag') for 
each argument in the query string. You shouldn't have to do anything 
except change $pag to $HTTP_GET_VARS['pag'].

dsb

***************************************       
David Scott-Bigsby
Product Manager, Web Site and PEDN

PureEdge Solutions
The Leader in Secure XML e-Forms

v:250-708-8145  f:250-708-8010
1-888-517-2675   www.PureEdge.com
***************************************


> -----Original Message-----
> From: Rodrigo Penloski - Som Livre.com
> [mailto:Rodrigo@s...]
> Sent: Tuesday, October 29, 2002 9:20 AM
> To: beginning php
> Subject: [beginning_php] RES: RE: switch problem
>
>
> Ok, i'll get with $HTTP_GET_VARS['pag'], but how do I send to it??
>
> -----Mensagem original-----
> De: David Scott-Bigsby [mailto:DScott-Bigsby@P...]
> Enviada em: ter=E7a-feira, 29 de outubro de 2002 14:03
> Para: beginning php
> Assunto: [beginning_php] RE: switch problem
>
>
> Rodrigo,
>
> > The variable $pag comes from another page through the URL:
> >
> > localhost/mytests/switch.php?pag=3Dname.
>
> You're doing it the "old way".
>
> PHP used to create variables for you based on the names in 
name=3Dvalue
> pairs, but, by default, this is turned off in more recent versions of
> PHP. You can turn this behaviour back on, although it's not
> recommended.
>
> You can get the query string values through the global array
> $HTTP_GET_VARS, e.g.,
>
> 	switch ($HTTP_GET_VARS['pag'])
> 	...
>
> There are other global arrays for the same purpose -- I think
> $HTTP_GET_VARS is deprecated in favour of $HTTP_GET or
> somesuch. (By not
> on my box -- we haven't upgraded yet.)
>
> dsb
>
> ***************************************       
> David Scott-Bigsby
> Product Manager, Web Site and PEDN
>
> PureEdge Solutions
> The Leader in Secure XML e-Forms
>
> v:250-708-8145  f:250-708-8010
> 1-888-517-2675   www.PureEdge.com
> ***************************************
>
>
> > -----Original Message-----
> > From: Rodrigo Penloski - Som Livre.com
> > [mailto:Rodrigo@s...]
> > Sent: Tuesday, October 29, 2002 6:43 AM
> > To: beginning php
> > Subject: [beginning_php] switch problem
> >
> >
> > I have this code:
> >
> > <?
> > switch ($pag) {
> > 	case 'name':
> > 	print "Joseph";
> > 	break;
> > =09
> > 	case 'mail':
> > 	print "joseph@s...";
> > 	break;
> > =09
> > 	case 'age':
> > 	print "21";
> > 	break;
> > =09
> > 	default:
> > 	print "default";
> > }
> > ?>
> >
> > The variable $pag comes from another page through the URL:
> >
> > localhost/mytests/switch.php?pag=3Dname.
> >
> > Well the problem is, it doesn't work..
> >
> > What am I doing wrong?
> >
> > Thanx in advance;
> >
> > Rodrigo
> >
> >
>
>
>

  Return to Index