On Tue, 14 Aug 2007 23:14:40 +0200, Water Cooler v2 <wt*****@yahoo.com
wrote:
>
><?php
define('FOO','bar');
$foz = '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 global,
PHP has some variable superglobals (like $_SERVER,$_POST,$_GET, etc.), but
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 the
global) it pretty easy, so easy it's done to death is scripts of starters.
--
Rik Wasmus