Re: How Do I make Global Scope Variables Available to Functions
| From: | Christoph M. Becker | Date: | Mon, 28 May 2018 07:37:25 +0000 |
| Subject: | Re: How Do I make Global Scope Variables Available to Functions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326487@lists.php.net to get a copy of this message | ||
On 28.05.2018 at 02:46, John wrote:
> I am writing a PHP script that has a number of variables that (I think) are in
> Global scope; that is, they are defined inline before the first command of the
> script. Note that these are not necessarily constants as shown in the example I
> included; most of them can be changed by the script.
>
> I have functions defined following these variables and before the commands in
> the script appear, but when they are called, the functions report the variables
> as undefined. This means I have to pass all the Globals to each function as a
> call argument.
>
> This seems odd but I don't see what I am doing wrong. Any suggestions?
See
<http://php.net/manual/en/language.variables.scope.php#language.variables.scope.global>.
--
Christoph M. Becker