Reply to Re: use of constants in an interpreter environment

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация