06-23-2008, 04:02 AM
|
#6 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
I'm not sure what he's up to there, but you only need to declare your variables global if you set them in the global scope (ie, outside a function, or inside a function that declares them global) and you want to use them inside of another function. ie
PHP Code:
// included file, echo.tpl -- echo $var; --
//your script
$var = "hello world!"; include ('echo.tpl'); // automagically recognizes $var, because the include is treated as though it were part of the parent script
function doesntWork() { echo $var; }
function works () { global $var
echo $var; }
doesntWork(); works();
If you placed those functions inside the include, they'd work (or not) the same as if they were directly part of the parent script.
-m
|
|
|
|