this is probably a very simple question... but how do I (if possible) set a variable and use it within a function...? eg:
$variable = "Matt"; function myFunction() { echo $variable; }
it throws a wobbler! How can I access it?
$variable = "Matt"; function myFunction() { global $variable; echo $variable; }
excellent - many thanks!! 🙂
If that function always needs that variable you really should pass it to the function when you call it -- ie
myFunction($variable);
Your function would look like:
function myFunction($mylocalcopy) { echo $mylocalcopy; }
that's usually how I do it in the past - but this is one file which needs configuration variables set at the top - its a plugin for some blog software - so to run it as one file is much easier 🙂
cheers for all the advice etc 🙂