Re: Variable scope

From: Date: Thu, 14 Mar 2002 16:34:52 +0000
Subject: Re: Variable scope
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-96060@lists.php.net to get a copy of this message
"Jason Wong" <php-general@gremlins.com.hk> wrote in message news:php.general-96048@news.php.net... > On Thursday 14 March 2002 21:53, George Nicolae wrote: > > I have the following code: > > > > <? > > function a($var_a) > > { > > b(); > > } > > > > function b() > > { > > global $var_a; > > echo $var_a; > > } > > > > a("hello word!"); > > ?> > > > > why function b() don't echo anything? > > Because $var_a has not, at any point, been defined in the global scope. how i declare $var_a as global? > > can I resolve this problem without > > calling b($var_a)? > > I'm curious as to what you're trying to achieve. Could you enlighten me? I have a big(=many lines) function "a()" and a little one "b()". I call function "b()" from function "a()" and alsow from many other php files. I need to midify the function "b()" without modify any other php files. That's why I don't want to use b($var_a). > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > > /* > "I will make no bargains with terrorist hardware." > -- Peter da Silva > */ Best regards, George Nicolae IT Manager ___________________ PaginiWeb.com - Professional Web Design www.PaginiWeb.com

« previous php.general (#96060) next »