Programming Code Center(PCC)
[PHP]

(PCC)::[How-to-Test-local-scope-(variable-inside-function)-in-php]::[php]

File Name : index.html

<!DOCTYPE html>
<html>
<body>

<?php
function myTest() {
    $x = 5; // local scope
    echo "<p>Variable x inside function is: $x</p>";
} 
myTest();

// using x outside the function will generate an error
echo "<p>Variable x outside function is: $x</p>";
?>

</body>
</html>

Output :

Variable x inside function is: $x

"; } myTest(); // using x outside the function will generate an error echo "

Variable x outside function is: $x

"; ?>