Join Now
Home Aptitude Reasoning DI VA GK CA CA Hindi Quiz Placements
What is the output of the following PHP code snippet?
<?php$x = 5;$y = 10;function myFunction() { global $x, $y; $y = $x + $y;}myFunction();echo $y;?>
5
10
15
None of the above
$myString[3]
$myString{3}
Both A and B
array_shift($myArray);
array_pop($myArray);
unset($myArray[0]);
All of the above
$myArray = array("red", "green", "blue");
$myArray = array(array(1, 2), array(3, 4));
$myArray = array(1, 2, 3 => array("a", "b", "c"));
$myArray = array("red", array("green", "blue"), "yellow");
$myArray = array("red", "green", "blue", "yellow");
$myArray = array(array("red", "green"), array("blue", "yellow"));
<?php$myString = "Hello, world!";echo substr($myString, 7);?>
Hello
world!
Hello, w
<?php$myVar = true;if ($myVar) { echo "The variable is true";} else { echo "The variable is false";}?>
The variable is true
The variable is false
1
<?php$num1 = 10;$num2 = 5;$result = $num1 + $num2;echo "The result is " . $result;?>
The result is 10
The result is 5
The result is 15
if ($myVar == null) { ... }
if ($myVar === null) { ... }
if ($myVar != null) { ... }
array_push($myArray, "newElement");
$myArray[count($myArray)] = "newElement";
$myArray[] = "newElement";