Programming - PHP
21.
What will be the output of the following PHP code?
<?php define('FOO', 10); $array = array( 10 => FOO, "FOO" => 20 ); print $array[$array[FOO]] * $array["FOO"]; ?>
Answer
Answer :
Option D22.
What will be the output of the following PHP code?
<?php function ExamAdda (&$array) { foreach ($array as &$value){ $value = $value + 2; } $value = $value + 3; } $array = array (1, 2, 3); ExamAdda($array); echo implode(', ',$array); ?>
Answer
Answer :
Option A23.
What will be the output of the following PHP code?
<?php $x = 5; $y = 10; function examAdda() { $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y']; } examAdda(); echo $y; ?>
Answer
$GLOBALS is a PHP super global variable which is used to access global variables from anywhere in the PHP script (also from within functions or methods).
PHP stores all global variables in an array called $GLOBALS[index]. The index holds the name of the variable.
Answer :
Option DExplanation :
$GLOBALS is a PHP super global variable which is used to access global variables from anywhere in the PHP script (also from within functions or methods).
PHP stores all global variables in an array called $GLOBALS[index]. The index holds the name of the variable.
24.
What will be the output of the following PHP code?
<?php function b($a = 4) { $a = $a / 2; return $a; } $a = 10; b($a); echo $a; ?>
Answer
In the given script, the output will be 10 since the value of variable $a will not be affected by the value of $a inside the function b() (due to function scope)
Answer :
Option BExplanation :
In the given script, the output will be 10 since the value of variable $a will not be affected by the value of $a inside the function b() (due to function scope)
25.
What will be the output of the following PHP code?
<?php function swings(&$park){ $park++; $park = roundabout($park); } function roundabout($park){ $park *= 2; } $park = 17; echo swings($park); ?>
Answer
Function does not return anything.
Answer :
Option EExplanation :
Function does not return anything.
Jump to page number :