This site is mobile accessible. Press the "Tap Here" button to use a different font-size.
Smartphone icons created by Freepik - Flaticon
Variable x inside function is: 5
Variable x outside function is:
<?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>"; ?>
You can have local variables with the same name in different functions, because local variables are only recognized by the function in which they are declared.