Enter your Sign-on user name and password.

Forgot password?
  • Follow us on:
Loading video...

Start Learning Now

Our free lessons will get you started (Flash® 10 required).
Get immediate access to our entire library.

Sign up for Educator.com

Features Overview

  • Get on-demand access to our complete library
  • Search and jump to exactly what you need to learn
  • Track your progress
  • Download practice and lesson files
  • *Ask questions and get answers from our community & instructors

Variable Scope

  • Variable scope refers to the part of a script where a variable can be accessed.
  • Variables defined in a script outside of a function have global scope . A variable with global scope can be used anywhere within the script it is defined or the files included in the script it is defined (*except within functions).
  • Variables defined in functions, including function parameters, have what is known as local function scope . Variables with local function scope can only be accessed from within the function.
  • The global keyword allows variables with global scope to be used within functions and variables with local function scope to be used in the global scope.
  • Superglobal variables are pre-defined associative array variables that are always available in both the global scope and local function scope.
  • The $GLOBALS superglobal contains all of the variables currently in the global scope of a script. It can be used to access global variables from within local function scope.
  • All constants are accessible in both the global and local function scope.
  • Functions have global scope, meaning as long as a function is defined within a script or one of its include files, it can be called anywhere within that script or its include files.
  • Additional Resources:

Variable Scope

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

Computer Science: Introduction to PHP