Beginner PHP
Q23 / 100

What is the scope of a variable defined inside a PHP function?

Correct! Well done.

Incorrect.

The correct answer is B) Local — accessible only within that function

B

Correct Answer

Local — accessible only within that function

Explanation

PHP functions have their own scope. To access a global variable inside a function, use the global keyword or $GLOBALS superglobal.

Progress
23/100