Re: [PHP4BETA] Global variables inside a function?
| From: | Lars Torben Wilson | Date: | Wed, 05 Apr 2000 18:58:25 +0000 |
| Subject: | Re: [PHP4BETA] Global variables inside a function? | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-13176@lists.php.net to get a copy of this message | ||
Peter Kovacs writes:
> Is there an easy and efficient way to declare all the global variables to
> be global within a function?
>
> Peter
>
> --------------------------------------------------
> Peter D. Kovacs KnowPost.com LLC
> Lead Engineer peter@knowpost.com
> --------------------------------------------------
In PHP4, this is simple: just put 'extract( $GLOBALS );' at the
beginning of the function definition:
<?php
$booger = 'This is a test';
function foo() {
extract( $GLOBALS );
echo $booger;
}
foo();
?>
Cheers,
Torben
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+