PHP - Functions
What will be the output of the following PHP code?
$x = 5;
function test() {
$x = 10;
echo $x;
}
test();
echo $x;$x = 5;
function test() {
$x = 10;
echo $x;
}
test();
echo $x;test(), $x is assigned 10 locally, so echo $x; prints 10.$x remains 5 because the local $x inside the function does not affect the global $x.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions