|
Posted by Rik on 08/14/07 21:22
On Tue, 14 Aug 2007 23:14:40 +0200, Water Cooler v2 <wtr_clr@yahoo.com> =
=
wrote:
>
>> <?php
>> define('FOO','bar');
>> $foz =3D 'baz';
>> function test(){
>> echo FOO;
>> echo $foz;}
>>
>> test();
>> ?>
>
>
>
> I tried it on my machine. Shows a blank page.
There's something wrong with your machine. It should return 'bar', =
followed by either nothing or an error message $foz is not defined, =
depending on error settings.
> Is your argument that
> variables are limited by scope whereas constants have global (and not
> superglobal) scope?
The term 'superglobal' indicates that a constant is automatically =
global--i.e., automatically available in every scope, without the use of=
=
either the global keyword or the $GLOBALS array. A variable can be globa=
l, =
PHP has some variable superglobals (like $_SERVER,$_POST,$_GET, etc.), b=
ut =
there is no way to make a normal user-defined variable a superglobal. =
Putting variables in global scope (so not available in any scope, just t=
he =
global) it pretty easy, so easy it's done to death is scripts of starter=
s.
-- =
Rik Wasmus
[Back to original message]
|