RE: [PHP] [Newbie] PHP Variables

From: Date: Fri, 09 Feb 2001 19:46:53 +0000
Subject: RE: [PHP] [Newbie] PHP Variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-38997@lists.php.net to get a copy of this message
Thx, I forgot to set the register_globals to On !!! -----Original Message----- From: Steve Edberg [mailto:sbedberg@ucdavis.edu] Sent: vrijdag 9 februari 2001 20:41 To: Steve Haemelinck Cc: PHP Mailing Listl (E-mail) Subject: RE: [PHP] [Newbie] PHP Variables At 8:06 PM +0100 2/9/01, Steve Haemelinck wrote: >I just wanted to try this: > >I take a link : http//www.xy.com/index.php?contents=HOME > >There I echo contents > ><?php echo $contents?> ><div align="center"><?php echo $contents; ?></div> > >It should display HOME? But it does not ! Two possibilities I can think of: (1) Is your echo statement above within a function? If so, you have to globalize it, or pass it as a function parameter: function zaphod($beeblebrox) { return '<div align="center">'. $beeblebrox. '</div>'; } echo zaphod($contents); or function zaphod() { global $contents; return '<div align="center">'. $contents. '</div>'; } echo zaphod(); See http://www.php.net/manual/en/language.variables.scope.php for more info. (2) The register_globals parameter is not set. This must be on if you want GET/POST/COOKIE etc. parameters to be automagically converted to variables. This can be set in php.ini, .htaccess, or httpd.conf, and can also be programmatically set and checked via ini_set() and ini_get(), respectively. If this is NOT set, you'll have to refer to your GET parameter as $HTTP_GET_VARS['contents'] See http://www.php.net/manual/en/configuration.php http://www.php.net/manual/en/language.variables.external.php http://www.php.net/manual/en/function.ini-set.php http://www.php.net/manual/en/function.ini-get.php for more info. - steve > > -----Original Message----- >From: Brian V Bonini [mailto:brian@gfx.cncdsl.com] >Sent: donderdag 8 februari 2001 23:55 >To: Steve Haemelinck >Subject: RE: [PHP] [Newbie] PHP Variables > >you can, what's the rest of your script look like. > >> -----Original Message----- >> From: Steve Haemelinck [mailto:steve.haemelinck@pandora.be] >> Sent: Thursday, February 08, 2001 3:49 PM >> To: PHP Mailing Listl (E-mail) >> Subject: [PHP] [Newbie] PHP Variables >> >> >> I thought you can pass variables in PHP as in CGI. >> >> http://www.xy.com/index.php?contents=HOME >> >> contents should be available as variable, but it does not seem to >> work. Doe > > anyone has an idea why not? >> -- +--- "They've got a cherry pie there, that'll kill ya" ------------------+ | Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +-------------------------------------- FBI Special Agent Dale Cooper ---+

« previous php.general (#38997) next »