Key Concepts

Review core concepts you need to learn to master this subject

PHP Variable Scope

<?php $x = 6; function scope(){ $y = 7; echo $x; // prints 'undefined variable' global $x; echo $x; // prints 6 echo $y; // prints 7 } scope();

A variable with local scope can only be accessed within the function it is declared. A variable with global scope can be accessed from multiple functions in the PHP script.

Introduction to PHP Functions
Lesson 1 of 1

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo