Function Scope

suggest change

A variable assigned inside a function is local to that function. It does not change a variable of the same name outside the function.

$number = 5;
function foo(){
    $number = 10;
    return $number;
}

echo foo(); // Prints 10
echo $number; // Prints 5. The assignment inside foo did not change this variable.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents