Code below prints produces error:
Notice: Undefined variable: x in C:\wamp\www\h4.php on line 9
and output:
Variable x inside function is:
Variable x outside function is: 5
Code:
<html>
<body>
<?php
$x = 5; // global scope
function myTest() {
// using x inside this function will generate an error
echo "<p>Variable x inside function is: $x</p>";
}
myTest();
echo "<p>Variable x outside function is: $x</p>";
?>
</body>
</html>
What gets wrong with x
global variable inside of myTest
function?