What is the potential issue with using global variables in PHP functions, as seen in the provided code snippet?

Using global variables in PHP functions can lead to code that is difficult to maintain and debug. It can make functions less reusable and increase the risk of unintended side effects. To solve this issue, you can pass the necessary variables as arguments to the function instead of relying on global variables.

// Original code with global variable
$globalVar = 10;

function multiplyByGlobal($num) {
    global $globalVar;
    return $num * $globalVar;
}

echo multiplyByGlobal(5); // Output: 50

// Code with passing variable as an argument
$globalVar = 10;

function multiplyByArg($num, $globalVar) {
    return $num * $globalVar;
}

echo multiplyByArg(5, $globalVar); // Output: 50