$variable = 10; // Global variable function shadowingExample() { $variable = 5; // Local variable with the same name echo $variable; // Output: 5 } shadowingExample(); echo $variable; // Output: 10 (global variable is not modified)
$variable = 10; // Global variable function shadowingExample() { $variable = 5; // Local variable with the same name echo $variable; // Output: 5 } shadowingExample(); echo $variable; // Output: 10 (global variable is not modified)