Global and Local scope
code bellow:
-------------
<!DOCTYPE html>
<html>
<body>
<?php
$x = 5; // global scope
function myTest() {
$x = 55; // local scope
echo "<p>Variable x inside function is: $x</p>";
}
myTest();
echo "<p>Variable x outside function is: $x</p>";
?>
</body>
</html>
-------------
output:
Variable x inside function is: 55
Variable x outside function is: 5
No comments:
Post a Comment
Add your comment here.