FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » A Few Noob Questions
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: A Few Noob Questions [message #175148 is a reply to message #175127] Tue, 16 August 2011 21:30 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to integrate paypal payment Indian currency support ..?
Next Topic: Looking for good C and C++ PHP plugin examples
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 13:12:39 GMT 2024

Total time taken to generate the page: 0.04001 seconds