The output of ofllowing script would be $somerar=15; function ad it () { GLOBAL $somevar; $somerar++ ; echo "somerar is $somerar"; } addit ();

  1. somerar is 15

  2. somerar is 16

  3. somerar is 1

  4. error in code


Correct Option: B
Explanation:

To solve this question, the user needs to understand the concept of global variables and function in PHP. The script defines a global variable named $somevar with a value of 15, and a function named addit() that increments the value of $somevar by one and then outputs its new value. The function explicitly states the variable is global using the global keyword.

When the addit() function is called, it will first increment the value of $somevar by one, resulting in a value of 16. Then, the function will output the string "somerar is 16" using the echo statement.

Therefore, the correct answer is:

The Answer is: B. somerar is 16

Find more quizzes: