Posted by Steve on 01/07/06 23:48
On Sun, 08 Jan 2006 10:33:00 +1300, windandwaves wrote:
> Hi Folk
>
> Consider this:
>
> ---foo1.php
> $myvar = 10;
>
> --- foo2.php
> require_once("foo1.php");
>
> function funky {
> echo $myvar;
> }
>
> from my experience, funky does not print 10. How do I make $myvar "global"
> (not sure if this is the right word) so that it shows everywhere.
A search on global might have helped (:
<?
$myvar = 10;
function funky ()
{
global $myvar;
echo $myvar;
}
funky ();
?>
Navigation:
[Reply to this message]
|