Question:What is the value displayed when the following is executed? Assume that the code was executed using the following URL:
testscript.php?c=25<?php
function process($c, $d = 25){
global $e;
$retval = $c + $d - $_GET['c'] - $e;
return $retval;
}
$e = 10;
echo process(5);
?>
+ ExplanationThis question is designed to test your knowledge of how PHP scopes variables when dealing
with functions. Specifically, you must understand how the global statement works to bring
global variables into the local scope, and the scope-less nature of superglobal arrays such as $_GET, $_POST, $_COOKIE, $_REQUEST and others. In this case, the math works out to 5 + 25 - 25 – 10, which is -5, or answer B.