Re: PHP 4.0 Bug #2193 Updated: Global declared variables not gobalu
| From: | Michal Kara | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: PHP 4.0 Bug #2193 Updated: Global declared variables not gobalu | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-10353@lists.php.net to get a copy of this message | ||
> ID: 2193
> Updated by: zeev
> Reported By: lemming@k332.feld.cvut.cz
> Status: Closed
> Bug Type: Scripting Engine problem
> Assigned To:
> Comments:
>
> Your code is wrong.
> When you include a file from within a function, the included
> code is executed in the scope of that function. Thus, when you
> include t1.php from Test2(), $T=1 is executed in the scope of
> Test2(), and does not become a global variable. For that reason,
> global $T inside Test() does not attach to this variable.
>
I understand this. But:
a) Code which works standalone does not work when included from
a function, which IMHO is not a good behavior.
b) There is no simple way for the function to access the variable.
c) It should be noted win the "variable scope" chapter in the manual.
Michal Kara alias lemming