RE: [PHP] function()

From: Date: Tue, 05 Nov 2002 23:49:49 +0000
Subject: RE: [PHP] function()
Groups: php.general 
Request: Send a blank email to php-general+get-122891@lists.php.net to get a copy of this message
FYI: 'global' is two way eg: <? function test() { global $foobar; $foobar = "Hello World"; } test(); echo $foobar; ?> will work. -----Original Message----- From: Justin French [mailto:justin@indent.com.au] Sent: Wednesday, November 06, 2002 11:49 AM To: php-general@lists.php.net Subject: Re: [PHP] function() Doesn't 'global' only get variables from outside the function into it???? OP (I think) wanted the variables within the function to work outside it. Justin on 06/11/02 2:44 AM, Jason Wong (php-general@gremlins.com.hk) wrote: > On Tuesday 05 November 2002 23:56, Francisco Vaucher wrote: > >> This doesn't work. I need to get some variables values out of the function. >> Is there a way to make te variables defined in the function 'global' ? So I >> can use them after the function call. > > Declare them as global: > > <? > doo(123); > echo $dah; > > function doo($param) { > global $dah; > > $dah = $param * $param; > } > ?> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#122891) next »