Re: quick globalisation?
| From: | Curt Zirzow | Date: | Wed, 25 Aug 2004 06:19:47 +0000 |
| Subject: | Re: quick globalisation? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194657@lists.php.net to get a copy of this message | ||
* Thus wrote Justin French:
> Jay,
>
> "global $a, $b, $c" is used for bringing global variables INTO the
> scope of the function... what I'm after is a way of making localised
> variables (in function) available outside of the function.
<?php
$a = 1;
function foo() {
global $a, $b;
$a = 2;
$b = 3;
}
echo $a, ':', $b, "\n";
foo();
echo $a, ':', $b, "\n";
results:
1:
2:3
remember 'global $a' is the same as doing:
$a = &$GLOBALS['a'];
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!