I'm new to php, and cannot understand the logic below.
<?php
$user = "abc";
function test(){
$user = "def";
echo $user;
}
function test_2(){
$user = "xyz";
return $user;
}
echo $user;
echo "<br />";
test();
echo "<br />";
echo test_2();
echo "<br />";
echo $user;
?>
When "echo-ing" $user, function test_2() overwrites the value of $user and prints "xyz". But when I simply echo $user [after echo test_2() ], but it prints "abc"; I mean it should again print "xyz" as object $user stores the value "xyz". Can you please explain how does the functions mechanism works here.