function myTest() { $x = 5; // local scope echo "

Variable x inside function is: $x

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

Variable x outside function is: $x

";