stupid question, WITH: function tep_db_close($link = 'db_link') { global $$link; return mysql_close($$link); } (ignore the function-ality) WHY have (the programmers of oscommerce) done $LINK - like global $$link;? Surely that means $db_link. And So why not say "global $db_link;" It's not even a dynamic variable name - because it's set above (assuming that variables set in a function () parentheses behave the same as normal. IF they had said $link = CONSTANT_NAME, and that was settable elsewhere - i could see the reasoning. also - this is one of a list of functions - all with the same $link = 'db_link' thing in their ... "header" () parentheses [i don't know what to call it]. Any ideas? nicholas.
hmm variable variables kindly hav a look here: http://www.php.net/manual/en/language.variables.variable.php
Cheers... i got that though... The answer is that they WERE setting only a DEFAULT value... so $link could equal "shoes" in the function - were "shoes" passed to it - the defualt ('db_link') would be over-rulled. Like this: function defualt_values_test ($a = 123, $b = 456){ echo "a = ".$a."<br/>"; echo "b = ".$b."<br/>"; echo "<br/>"; } defualt_values_test(); // uses values set in 'header' defualt_values_test('overwritten',987654321); // uses these values defualt_values_test($non_existant,"var A has to be overwritten."); // you can only use this for the last vars. OUTPUTS ---------- a = 123 b = 456 a = overwritten b = 987654321 a = b = var A has to be overwritten.
Just have to say I'm not a big fan of variable variables (although they can be useful) and I'm even less a fan of global variables. Maybe my brain can't keep track of them... http://www.google.com/search?q=php avoid global variables