Most of the time that's done with a global variable. As you probably know, all variables inside of PHP functions are local to that function. If you declare a variable outside of any functions you can make it accessible within whatever function(s) you choose. Example:
<?PHP
$serverName = "mysql.myserver.com";
echo $serverName; //returns "mysql.myserver.com"
private_server_name();
echo $serverName; //still returns "mysql.myserver.com" because private_server_name() didn't change the global variable
public_server_name();
echo $serverName; //returns "public.myserver.com" because the function used the global variable
function private_server_name() {
$serverName = "private.myserver.com"; // changes the value of the variable $serverName only within the scope of this function.
}
function public_server_name()
global $serverName; //tells this function that it should use the $serverName variable defined outside the function.
$serverName = "public.myserver.com"; //changes the global value
}
I hope this clears things up instead of increasing confusion. If you want more info check out the PHP manual on variable scopes.