note 9190 modified in Variable scope by ronabop
| From: | ronabop@php.net | Date: | Wed, 13 Dec 2000 06:14:47 +0000 |
| Subject: | note 9190 modified in Variable scope by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-8677@lists.php.net to get a copy of this message | ||
you can define a global varible from within a function or object:
<?php
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/variable-scope.php