<?php
/// how to define a variable in a function to use globals
function myCode(){
$GLOBALS['magic'] = "what";
}
myCode(); /// -- run function
echo $magic; //<-- OUTPUT WHAT.
function test(){
echo $GLOBALS['magic']; /// <-- output What
};
?>
Thursday, January 31, 2013
Define Variable in Function to use GLOBALLY
Need to define a variable within a function, but you'd like to use it throughout your script.....
here is an example on how to create it and how you can use it.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment