Re: A Few Noob Questions [message #175154 is a reply to message #175148] |
Wed, 17 August 2011 00:31 |
eBob.com
Messages: 11 Registered: August 2011
Karma:
|
Junior Member |
|
|
Thank you very much Denis. But now I have to ask ... How global are the
$GLOBALS? From you answer I assume that $GLOBALS have a scope which exceeds
one file. But how far beyond one file?
Are there any kind of read/write variables which are shared between users?
Thanks, Bob
"Denis McMahon" <denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote in message
news:4e4ae161$0$27229$a8266bb1(at)newsreader(dot)readnews(dot)com...
> On Tue, 16 Aug 2011 11:02:40 -0400, eBob.com wrote:
>
>> How can the "units" of PHP between tags communicate? Can my PHP code
>> create $GLOBALS variables? How about $_SESSION variables?
>
> PHP processes a file. Within a file, you may have bunches of php code
> between "<?php" and "?>" tags, and may also have text output. The php
> code may include other files in various ways.
>
> All the code in the file, including in any included files, that is not
> part of a separate function definition operates in the same variable
> context.
>
> So, assuming between these cutlines is a single file:
>
> ------------8<------------
> <?php
> $a = 6;
> ?>
> output this text
> <?php
> echo $a . "\n"; // uses the previously defined value for $a
> ?>
> ------------8<------------
>
> If I save that as "basic.php" and then execute it in the cli:
>
> ~$ php basic.php
> output this text
> 6
>
> ~$
>
> Rgds
>
> Denis McMahon
|
|
|