Re: [PHP-DEV] Re: PHP 4.0 Bug #2193 Updated: Global declared variables not gobalu From: Zeev Suraski (zeev <email protected>)
Date: 08/30/99

At 18:26 30/08/99 , Michal Kara wrote:
>a) Code which works standalone does not work when included from
>a function, which IMHO is not a good behavior.

I'll have to say that in this case, your opinion is simply
wrong. Include() and require() execute the code in an included file as is
and in the context of the include/require statement. Many factors can
affect the way it behaves, including whether or not it is in a function
scope. If you got any other impression - you got it wrong...

>b) There is no simple way for the function to access the variable.

That's the idea of scope. You're not supposed to address any function
local variables. You have to intentionally declare variables as global if
you want them accessible from other scopes.

>c) It should be noted win the "variable scope" chapter in the manual.

Well, provided the explanation of include and require are clear, it's not
special in any way. Include()ing or require()ing a file is identical to
copying and pasting the contents of that file where the include/require
statement is, and scope rules apply all the same.

Zeev

--
Zeev Suraski   <zeev <email protected>>  http://www.zend.com/
For a PGP public key, finger bourbon <email protected>

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>