How can the issue of variable passing in PHP be resolved in the given code snippet?
The issue of variable passing in PHP can be resolved by using the global keyword to access global variables within a function. By declaring the variable as global inside the function, it can be modified and accessed without any issues. This ensures that the variable is passed correctly and retains its value throughout the program.
$number = 10;
function multiplyByTwo() {
global $number;
$number *= 2;
}
multiplyByTwo();
echo $number; // Output: 20