dico wrote:is there a way i can set all variables to global?
Depending on the structure of your code, you might try just storing all variables into an array and then you'd simply need to globalize that single array. For example:
$cfg_user = 'blah';
$cfg_pw = 'blah2';
$cfg_db = 'blah3';
function yourFunction() {
global $cfg_user, $cfg_pw, $cfg_db; // etc. etc. takes too long, right?
}
$cfg = array('user' => 'blah', 'pw' => 'blah2', 'db' => 'blah3');
function myFunction() {
global $cfg;
echo $cfg['user']; // blah
echo $cfg['pw']; // blah2
// etc.
}
dico wrote:Alternatively, if I have something like $variable[$x][$y], how can I set that as global -- or even pass it to the function?
To globalize items in arrays, just globalize the array itself.
function myFunction($x, $y) {
global $variable;
echo $variable[$x][$y];
}