How Variable Scope Works in PHP, Variable Scope Explained, Local vs Global Scope, PHP Function Scope

Channel:
Subscribers:
7,740
Published on ● Video Link: https://www.youtube.com/watch?v=u_ubFGaQG6c



Duration: 4:57
97 views
0


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.




Other Videos By We Will Code


2022-05-03How to Read PHP Documentation, Reading PHP Documentation, How to Learn the PHP Documentation Easy
2022-05-03Generating Random Numbers in PHP, Random Number Function with PHP, Learn to Generate Random Numbers
2022-05-02Working With Number Functions in PHP, abs PHP Function for Calculate Absolute Value, Round Function
2022-05-02Working with Substrings in PHP, Substring Built-In Functions, Find Matching String in PHP Codecademy
2022-05-02Different Built-In PHP String Functions Explained, Learn PHP Functions for Strings, Codecademy PHP
2022-05-02New JLAB Talk Go Microphone, Most Affordable Good Quality Vocal Microphone, Clear Vocal Microphone
2022-04-30Working with Variables in PHP, gettype function, PHP var_dump function, Learn PHP Built-In Functions
2022-04-25Is Echo a Function in PHP, Constructs Vs Functions in PHP, Echo is Not a Function, PHP Did You Know
2022-04-25Intro to Built-In PHP Functions, How to Use Built-In PHP Functions, Built-In Functions in PHP Guide
2022-04-24Review of PHP Functions, Intro to PHP Functions, Review, Create a PHP Function, Invoke a Function
2022-04-22How Variable Scope Works in PHP, Variable Scope Explained, Local vs Global Scope, PHP Function Scope
2022-04-21What is Pass By Reference in PHP, Pass By Reference Explained, Learn PHP Codecademy, Parameter Alias
2022-04-21Default Parameters in PHP, Default Parameters in Functions, PHP on Codecademy PHP Default Arguments
2022-04-20Multiple Parameters in PHP, Using Multiple Function Parameters in PHP, Codecademy Learn PHP Coding
2022-04-19Function Parameters Explained, What are Parameters and Arguments in PHP, Passing in Arguments in PHP
2022-04-19What is Null in PHP, Returning Null Explained in PHP, Null Values in Programming, Codecademy PHP
2022-04-19PHP Function Return Values, PHP Return Values Explained, Codecademy PHP, Understand Return Values
2022-04-19More on Return Statements, PHP Codecademy Free Programming Course, PHP Return Keyword, PHP Functions
2022-04-19Return Statements Explained, What is a Return Statement in PHP, Codecademy PHP, Return Statements
2022-04-18Invoking Functions Explained in PHP, How to Invoke a Function in PHP, Function Invocation Codecademy
2022-04-18Defining Functions in PHP, How to Define a Function in PHP, Codecademy Learn PHP, Create A Function



Tags:
Coding
Learn PHP
PHP
Programming
Server-side
back-end
code tutorial
tutorials