<?php
header("Content-type:text/html;charset=utf-8");
$x=5; // Global variables
function myTest()
{
$y=10; // Local variable
global $x;
echo "<p>Variables in the test function:<p>";
echo "Variable x is: $x";
echo "<br>" ;
echo "Variable y is: $y";
}
myTest();
echo "<p>Test function external variable:<p>";
echo "Variable x is: $x";
echo "< ;br>";
echo "Variable y is: $y"; //Output error Notice: Undefined variable:
?>
# #
This is a problem with his editor. You can try it in your own editor and it will display normally
.... Take a closer look. $y is a local variable. You must have made an error when echoing $y outside the function. This variable is not defined