<html>
<body>
$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>
<!-- Mirrored from www.w3schools.com/php/phptryit.asp?filename=tryphp_var_global by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 02:29:30 GMT -->
</html>