note 9190 added to Variable scope

From: Date: Sat, 21 Oct 2000 19:57:45 +0000
Subject: note 9190 added to Variable scope
Groups: php.notes 
Request: Send a blank email to php-notes+get-6797@lists.php.net to get a copy of this message
you can define a global varible from within a function or object: <? class foo { function bar() { global $somevar; $somevar = "somevar is set"; } function moo() { global $someothervar; $someothervar = "someothervar is set"; } $thisvar = new foo; $thisvar->bar(); moo(); echo $somevar; echo "<br>"; echo $someothervar; ?> http://www.php.net/manual/language.variables.scope.php

« previous php.notes (#6797) next »