actually, Daniel, that reminds me: constants.
You can make a value available *anywhere* in your script by defining it as a "constant":
PHP Code:
<?php
define('MY_VAR', 'I am constant as the northern star');
echo MY_VAR; // works
function local_scope(){
echo MY_VAR; // also works
}
?>
However, constants can only be scalar values (e.g., integer, float, string, boolean - arrays, objects, functions, expressions, etc. don't work).
PHP Code:
<?php
define('MY_VAR', 'constant'); // scalar; works
define('MY_VAR2', MY_VAR.' 2'); // two scalars; also works
define('MY_VAR', 1+2); // expression; doesn't work
define('MY_VAR', my_function()); // doesn't work, even if the function returns a scalar value
// etc.
?>
Bookmarks