In this PHP programming lesson, we take a look at How Variable Scope Works in PHP, Variable Scope Explained, Local vs Global Scope, PHP Function Scope on Codecademy’s Learn PHP course. This is a continuation lesson based on the “Introduction to PHP Functions” section. Here we are learning about a function’s local scope, and how if we want to refer to a variable that is in the global scope (outside of any code block) then we must use the global keyword when we refer to a variable within the scope of our function. To pass arguments into a function then returning values is one way to define how our function interfaces with the rest of our code. It is the preferred method to exchange data within our program. This is because it is clear to see the data that a function will depend on from its parameter list. When many functions depend on the same variable information, it may be beneficial to have that variable accessible anywhere without having to be passed in. This is what the “global” keyword helps us do. The “global” keyword will tell PHP to look in our code’s global scope for a variable with that name. Learn to use the variable scope to master local and global scope in programming. Practice using the local scope, and practice using the global scope. Make sure to understand the variable scope before moving on. Thanks for watching How Variable Scope Works in PHP, Variable Scope Explained, Local vs Global Scope, PHP Function Scope.