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
<?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
What is the output of the following code snippet?
<?php$x = 5;$y = 10;$z = $x + $y;echo "The sum is: $z";?>
The sum is: 15
The sum is: $z
The sum is: 5 + 10
array_shift($myArray);
array_pop($myArray);
unset($myArray[0]);
All of the above
foreach ($myArray as $value) { ... }
foreach ($myArray as $key) { ... }
foreach ($myArray as $key => $value) { ... }
<?php$colors = array("red", "green", "blue");echo $colors[1];?>
red
green
blue
<?php$myString = "Hello, world!";echo substr($myString, 7);?>
Hello
world!
Hello, w
<?php$x = 5;echo ++$x;?>
6
<?php$myArray = array("red", "green", "blue");echo count($myArray);?>
3
red, green, blue
Array