在函数之外指定全局变量

I have a pretty long extensive function, and the only thing that would change for me to use it elsewhere in the application would be to change the global variable declared inside of it.

function some_function() {
  global $sys;

  // ... Do stuff

}

some_function();

I need to change global $sys; to global $lang; or possibly a few other things, but everything else would stay the same. I was thinking something like:

function some_function($global_var) {
  global $global_var;

  // ... Do stuff

}

some_function($sys);

... or maybe ...

some_function($lang);

How can this be done?

Instead of using global, you could just pass the "global var" as a parameter to the function by reference:

function some_function(&$global_var) {

    // ... Do stuff

}

Then you could use this function elsewhere without requiring to change the "global var" name.

Also consider the use keyword to import a variable from outside the scope instead of working in the global scope.