What would the following code print to the browser? Why?


Top Questions

<?php
$num
= 10;
function
multiply(){
$num = $num * 10;
}
multiply();
echo
$num;
?>

Ans: 10 because,its a call by value.$num is static here. change the above code as

<?php
$num
= 10;
function
multiply(){
global
$num ;
$num = $num * 10;
}
multiply();
echo
$num;
?>
ANS: 100

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
15 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Check It !

Tweet It

W3 Updates

Stay informed on our latest news!

Syndicate content