Each PHP script is run in one instance, and the only things sent from script to script are sent with the HTTP headers for each request. There are only 4 ways to pass information on from one script to another.
Sessions
[indent]Sessions are probably the easiest way. You just store what you want in an array called $_SESSION after calling [man]session_start/man at the top of your script. Any script that wants access to the session, then you must call [man]session_start[/man] at the top of them.[/indent]
Cookies
[indent]Cookies are stored client-side in text files and can be manipulated by the user. They're available via the $_COOKIE array after being created with [man]setcookie/man.[/indent]
URL Variables
[indent]These are seen in the URL bar of the browser as the ?variable=value&variable2=value2 part of urls. You can [man]urlencode/man the values you want to pass on, and put them in a query string like ?something=somethingelse.[/indent]
Hidden Forms
[indent]These are forms with no manual input fields, but rather all the fields are "hidden" and navigation to the next page requires the clicking of a "submit" button for the hidden form. Then on the receiving script you can use the $POST array to gather data from the posted hidden form (or $GET if the method is "get").[/indent]
Those are really the only ways to pass data from one page to another.
What you are thinking about is when you have functions that need to share data between them and you don't necessarily want to return variables and stuff. An example:
<?php
$myVar = 'Some String';
function changeMyString($newString)
{
echo 'Previous to change: ' . $GLOBALS['myVar'];
// Bring the global variable into this function's scope
global $myVar;
$myVar = $newString;
}
changeMyString('Hello Moto!');
echo $myVar;
That should give you this output:
Previous to change: Some String
Hello Moto!