PHP Basics singleQuestion_answer
1/260
1.

Consider the following PHP script:

<html>
<head>
<title>
    This is a test script.
</title>
</head>
<body>
<?php
    echo (int) ((0.1 + 0.7) * 10);
?>
</body>
</html>

What will be the output of the PHP script?

2/260
2.

Assume that today is January 8th, 2013, 5:16:18 pm in MST time zone.

<?php
        echo date('l \t\h\e jS');
?>
3/260
3.

What is the result when the following PHP code involving a boolean cast is executed?

<?php
 var_dump( (bool) 5.8 );
?>
4/260
4.

Mark works as a Web Developer for Unicorn Inc. He develops an application in PHP using the following code:

<?php
      switch(1) {
      case 1: print("Book Details"); 
      case 2: print("Book Author"); 
      default: print("Missing Book");
      }
?>

What will be the output of the script?

5/260
5.

What is the output of the following PHP script?

    $a = 1;
    $b = 2.5;
    $c = 0xFF;
    $d = $b + $c;
    $e = $d * $b;
    $f = ($d + $e) % $a;
    echo ($f + $e);
6/260
6.

What will be the output of the following PHP code ?

<?php
for ($i = 0; $i % ++$i; $i++) 
{
    print"i";
}
?>
7/260
7.
<?php
    class Foo
    {
?>

<?php
        function bar()
        {
            print "bar";
        }
    }
?>

which is correct?

8/260
8.

What is the value of $x in the following code snippet?

<?php
$x = 123 == 0123;
?>
9/260
9.

What will this script output?

<?php
$a = "foo";
$$a = "bar";
$a = "Hello world";
echo ${"foo"};
?>
10/260
10.

How can a script come to a clean termination?

11/260
11.

What will the following script output?

<?php
    $x = 3 - 5 % 3;
    echo $x;
?>
12/260
12.

What will be the output of the following PHP code ?

<?php
$x = 1;
if ($x = $x&0)
    print $x;
else
    break;
?>
13/260
13.

what will the following code produce?

define('CONSTANT', 1);
define('_CONSTANT', 0);
define('EMPTY', '');
if(!empty(EMPTY)){
    if(!((boolean) _CONSTANT)){
        print "One";
    }
}
else if(constant('CONSTANT') == 1){
    print "Two";
}
14/260
14.

What will be the output of the following PHP code ?

<?php
 $a = 5; $b = -7; $c =0; 
 $d = ++$a && ++$b || ++$c;
 print $d; print $a;
?>
15/260
15.

Which of the following statements are true when applied to a Registry pattern? (choose two)

16/260
16.

What will be the output of the following PHP code ?

<?php
$i = 0;
do
{
    $i++;
}
while ($i < 3);
print $i;
?>
17/260
17.

What will be the output of the following PHP code ?

<?php
$b = 1; $c = 4; $a = 5; 
$d = $b + $c == $a;
print $d;
?>
18/260
18.

What will be the output of the following PHP code ?

<?php
$x = 1;
$y = 2;
if (++$x == $y++)
{
    echo "true ", $y, $x;
}
?>
19/260
19.

What is the output of the following PHP code?

<?php
    define('FOO', 10);
    $array = array(10 => FOO,"FOO" => 20);
    print $array[$array[FOO]] * $array["FOO"];
?>
20/260
20.

You run the following PHP script:

<? 
    $a = "b";
    $b = 20;
    echo $$a;
?>

What will be the output?

21/260
21.

What will be the output of the following PHP code ?

<?php
class Constants
{
    define('MIN_VALUE', '0.0');  
    define('MAX_VALUE', '1.0');  
    public static function getMinValue()
    {
        return self::MIN_VALUE;
    }
    public static function getMaxValue()
    {
        return self::MAX_VALUE;
    }
}
echo Constants::getMinValue();
echo Constants::getMaxValue();
?>
22/260
22.

The PHP syntax is most similar to:

23/260
23.

Which of the following data types are compound data types?

24/260
24.

What is the difference between isset() and other is_*() functions (is_alpha(), is_number(), etc.)?

25/260
25.

What will the output of this code be?

<?php
$result = echo print("Hello world!");
var_dump($result);
26/260
26.

What will be the output of the following PHP code ?

<?php
$b = 1;
switch($b)
{
case 1.0:
    print "hi";
    break;
case 1:
    print "hello";
    break;
default:
    print "hi1";
}
?>
27/260
27.

What will be the output of the following PHP code ?

<?php
     $one = "one";
     $two = "two";
     print($one,$two);
?>
28/260
28.

How should we add a single line comment in our PHP code?
i) /?
ii) //
iii) #
iv) /* */

29/260
29.

Which of the following is NOT a valid PHP variable name?

30/260
30.

What will be the output of the following PHP code ?

<?php
$i = 0;
while ((--$i > ++$i) - 1)
{   
    print $i;
}
?>
31/260
31.

Which of the following functions returns current Unix timestamp?

32/260
32.

42 with two decimal places?

33/260
33.

What is the output of the following?

<?php
$a = 0xf2 + 0x09;
$b = $a >> 3;
echo $b;
?>
34/260
34.

What is the output of the following PHP code?

       define("FOO", 10);
       $array = [10 => FOO, "FOO" => 20];
       echo $array[$array[FOO]] * $array["FOO"];
35/260
35.

What will be the output of the following PHP code ?

<?php
$var1 = 1 + ++5;
echo $var1; 
?>
36/260
36.

What will be the output of the following PHP code ?

<?php
$i = 0;
while ($i = 10)
{   
    print "hi";
}
print "hello";
?>
37/260
37.

What is the output of the following script?

<?php
$arr1 = [1,2,3];
$arr2 = array("1" => 2, 0 => "1", 2 => 3 );
$equal = $arr1 == $arr2 ? 'Equal' : 'Not Equal';
$identical = $arr1 === $arr2 ? 'Identical' : 'Not Identical';
echo "The arrays are [$equal] and [$identical]";
38/260
38.

Which of the below provided options is correct regarding the below code?

<?php 
    $a = array (1, 2, 3);
    $b = array (1 => 2, 2 => 3, 0 => 1); 
    $c = array ('a' => 1, 'b' => 2, 'c' => 3);
    var_dump ($a == $b); 
    var_dump ($a === $b); 
    var_dump ($a == $c); 
?>
39/260
39.

What will this script output?

<?php

class MyException extends Exception {}
class ChildException extends MyException {}

try {
    throw new ChildException;
} catch (Exception $e) {
    echo "Caught Exception: " . get_class($e);
} catch (MyException $e) {
    echo "Caught MyException" . get_class($e);
}
40/260
40.

What will be the output of the following code?

<?php
    function track() {
         static $count = 0;
         $count++;
         echo $count;
    }
    track();
    track();
    track();
?>
41/260
41.

What will be the output of the following PHP code?

<?php
   $team = "arsenal";
    switch ($team) {
        case "manu":
            echo "I love manu";
        case "arsenal":
            echo "I love arsenal";
        case "manc":
            echo "I love manc";
    }
?>
42/260
42.

Can I generate DLL files from PHP scripts like i can in Perl ?

43/260
43.

Which of the following code can be used to create case insensitive constant?

44/260
44.

Which of the following options shows the correct IF statement format?

45/260
45.

What would happen when the following code was run?

<?php
define('Tree', 'oak');
echo 'This tree is: ' . tree;
?>
46/260
46.

Who is the father of PHP?

47/260
47.

Choose the appropriate function declaration for the user-defined function is_leap(). Assume that, if not otherwise defined, the is_leap function uses the year 2000 as a default value:

<?php
    /* Function declaration here */
    {
        $is_leap = (!($year %4) && (($year % 100) || !($year % 400))); 
        return $is_leap;
    }
    var_dump(is_leap(1987)); /* Displays false */
    var_dump(is_leap()); /* Displays true */
?> 
48/260
48.

What will be the output of the following PHP code ?

<?php
$x;
for ($x = -3; $x < -5; ++$x)
{
    print ++$x;
}
?>
49/260
49.

What will be the output of the following PHP code ?

<?php
for(;;)
{
   print "10";
}
?>
50/260
50.

What will be the output of the following PHP code ?

<?php
$a = 1;
if (echo $a)
    print "True";
else
    print "False"; 
?>
51/260
51.

what is the output of the following script?

<?php
    function fibonacci ($x1, $x2)
    {
        return $x1 + $x2;
    }
    $x1 = 0;
    $x2 = 1;
    for($i = 0; $i < 10; $i++){
        echo  fibonacci ($x1, $x2). ',';
    }
?>
52/260
52.

What will be the output of the following PHP code?

<?php
    $color = "maroon";
    $var = $color[2];
    echo "$var";
    ?>
53/260
53.

Considering the following code, what will the output be?

<?php
$a = "0.0";
$b = (int)$a;
if ( (boolean)$a === (bool)$b) {
echo "True";
} else {
echo "False";
}
54/260
54.

Which version of PHP introduced Try/catch Exception?

55/260
55.

Which of the following tags should you avoid using to include php in htML?

56/260
56.

What will be the output of the following PHP code ?

<?php
$i = 0;
while (++$i && --$i)
{   
    print $i;
}
?>
57/260
57.

What does the following code snippet do?

$a = `ls -l`;
58/260
58.

What will be the output of the following PHP code ?

<?php
define('IF', 42); 
echo "IF: ", IF;
?>
59/260
59.

What will this script output?

<?php
function A() {
    try {
        b();
    } catch (Exception $e) {
        echo "Exception caught in " . __CLASS__;
    }
}
function B() {
    C();
}
try {
    A();
} catch (Error $e) {
    echo "Error caught in global scope: " . $e->getMessage();
}
60/260
60.

Which of the following type of variables are special variables that hold references to resources external to PHP (such as database connections)

61/260
61.

What will be the output of the following code snippet?

<?php
$a = 1;
$b = 2;
$c = 0xAF;
$d = $b + $c;
$e = $d * $b;
$f = ($d + $e) % $a;
print($f + $e);
?>
62/260
62.

What is the output of this code?

<?php
define('PI', 3.14159625);
define('_PI', "3.1459625");
$radius = 10;
if (PI == _PI) {
 $area = (int)PI * $radius ** 2;
 echo $area;
} else {
 echo "dhaka";
}
63/260
63.

What will be the output of the following PHP code ?

<?php
$x = 10;
$y = 20;
if ($x > $y && 1||1)
    print "hi" ;
else
    print "how are u";
?>
64/260
64.

How do we access the value of 'd' later?

$a = array(
    'a',
    3 => 'b',
    1 => 'c',
    'd'
);
65/260
65.

What will this code output?

    namespace A;
    function Hello() { echo __NAMESPACE__; }
    namespace B;
    function Hello() { echo __NAMESPACE__; }
    namespace C;
    \B\Hello();
66/260
66.

You run the following PHP script:

<php
     echo 0x33, ' birds sit on ', 022, ' trees.';
?>

What will be the output?

67/260
67.

What will be the output of the following PHP code ?

<?php
if (0.0)
    print "hi" ;
else
    print "how are u";
?>
68/260
68.

You run the following PHP script:

<?php
    $sale = 200;
    $sale = $sale- + 1;
    echo $sale;
?>

What will be the output?

69/260
69.

You run the following PHP script:

<? 
    echo (int) "1235Jason"; 
?>

What will be the output?

70/260
70.

What is the output of following code?

   $a = 1;
   ++$a;
    $a *= $a;
    echo $a--
71/260
71.

What will be the output of the following PHP code ?

<?php
$a = 10;
echo ++$a;
echo $a++;
echo $a;
echo ++$a;
?>
72/260
72.

What will be the output of the following PHP code ?

<?php
$i = "";
while ($i)
{   
    print "hi";
} 
while($i < 8) {
    $i++;
    print "hello";
}
?>
73/260
73.

What will be the output of the following PHP code ?

<?php
    $one = "one";
    $two = "one";
    print($one == $two);
?>
74/260
74.

What does the following function do, when passed two integer values for $p and $q?

<?php
function magic($p, $q)
{  
     return ($q == 0)    ? $p    : magic($q, $p % $q);
}
?>
75/260
75.

You developed a big application accessed by several thousand users at the same time. Suddenly, your web server stops responding and users are getting connection errors.What could have happened?

76/260
76.

What will be the output of the following PHP code ?

<?php
$color = red;
echo "$color" . red ;
?>
77/260
77.

What is the order of parameters in the mail() function?

78/260
78.

What will be the output of the following PHP code ?

<?php
$i = 0;
while ($i++)
{
    print $i;
}
print $i;
?>
79/260
79.

Consider the following script:

<?php 
      echo strtotime("january 1, 1901"); 
?>

What will be the output of the above PHP script if the older versions of glibc are present in the operating system?

80/260
80.

What will be the output of the following PHP code ?

<?php
const $b = 1;
switch($b)
{
case 1:
    print "hi";
    break;
case 1:
    print "hello";
    break;
default:
    print "hi1";
}
?>
81/260
81.

What will be the output of the following PHP code ?

<?php
$i = 5;
while (--$i > 0 || ++$i)
{   
    print $i;
}
?>
82/260
82.

Which PHP functions may be used to find out which PHP extensions are available in the system?

83/260
83.

What is the output of this PHP code?

<?php
echo (isset($a)) ? "A is set" : "A is not set";
echo " and ";
echo (empty($b)) ? "B is not set" : "B is set";
84/260
84.

What is the result of the following bitwise operation in PHP?

1 ^ 2
85/260
85.

Which of the following options is NOT as valid tag for PHP 7.1 script?

86/260
86.

Which one of the following four logical operators of PHP is not binary?

87/260
87.

What will be the output of the following PHP code ?

<?php
$b = 3;
switch($b)
{
case 2:
    print "hello";
    break;
case 1:
    print "hi";
    break;
}
?>
88/260
88.

What is the output of the following code snippet?

<?php
$a = 20;
function myfunction($b) {
    $a = 30;
    global $a, $c;
    return $c = ($b + $a);
}
print myfunction(40) + $c;
?>
89/260
89.

What will be the output of the following PHP code ?

<?php
$a = "1";
$b = "0";
if ((int)$a && $b) 
    print"hi";
else 
    print "hello";
?>
90/260
90.

What is the output of the following line of code?

<?php
echo "4" + 05 + 011 + ord('a');
?>
91/260
91.

How can we create a unique random password in PHP?

92/260
92.

What will be the output of the following PHP code ?

<?php
$a = 2;
if ($a-- - --$a - $a)
    print "hello";
else
    print "hi";
?>
93/260
93.

You run the following PHP script:

<?php
    $a=12;
    $b=11;   
    $a>$b ? print($a) : print($b);
?>
94/260
94.

You run the following script:

<?php
    $a=5 < 2;
    echo (gettype($a));
?>

What will be the output?

95/260
95.

Which of the following expressions multiply the value of the integer variable $a by 4?

96/260
96.

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);
?>
97/260
97.

Which of the following are the core extensions? Each correct answer represents a complete solution. Choose all that apply.

98/260
98.

What will this code output?

<?php
$a = 1.23;
$b = 4.56;
$c = (int)$a + (int)$b;
echo (double)$c;
99/260
99.

What will be the output of the following PHP code ?


<?php
$a = 1; $b = 1; $d = 1;
print ++$a + ++$a+$a++; print $a++ + ++$b; print ++$d + $d++ + $a++;
?>
100/260
100.

What will be the output of the following PHP code ?

<?php
for ($x = 0; $x <= 10; print ++$x)
{
    print ++$x;
}
?>
101/260
101.

Consider the following script:


<?php
    function myfunction($a, $b = true)
    {
        if($a && !$b) {
            echo "Hello, World!\n";
        }
    }
    $s = array(
         0 => "my",
         1 => "call", 
         2 => '$function', 
         3 => ' ',
         4 => "function", 
         5 => '$a',
         6 => '$b', 
         7 => 'a',
         8 => 'b',
         9 => ''
        );
    $a = true;
    $b = false;
    /* Group A */
    $name = $s[?].$s[?].$s[?].$s[?].$s[?].$s[?];
    /* Group B */
    $name(${$s[?]}, ${$s[?]});
?> 

Each ? in the above script represents an integer index against the $s array. In order to display the Hello, World! string when executed, what must the missing integer indexes be?

102/260
102.

Which of the following are valid identifiers (Choose 3)

103/260
103.

What will be the output of the following PHP code ?

<?php
$y = 2;
$w = 4;
$y *= $w /= $y;
echo $y, $w;
?>
104/260
104.

What will be the output of the following PHP code ?

<?php
$i = 0; $j = 1; $k = 2;
print !(($i + $k) < ($j - $k));
?>
105/260
105.

What will be the output of the following PHP code ?

<?php
$x = 10;
$y = 5;
$z = 3;
if ($x / $y / $z)
    print "hi";
else
    print "hello";
?>
106/260
106.

Which language construct can best represent the following series of if conditionals?

<?php
    if($a == 'a') {
        somefunction();
    } else if ($a == 'b') {
        anotherfunction();
    } else if ($a == 'c') {
        dosomething();
    } else {
        donothing();
    }
?> 
107/260
107.

What will be the output of the following PHP code?

 <?php
    $score = 1234;
    $scoreboard = (array) $score;
    echo $scoreboard[0];
    ?>
108/260
108.

You run the following script:

<?
    10 = $a;
    echo $a;
?>
109/260
109.

What is the output of this script?

<?php
$a = "apples" <=> "bananas";
$b = $a ?? $c ?? 10;
echo $b;
110/260
110.

What will be the output of the following PHP code ?

<?php
$var1 = 1;
echo $var1 = ++$var1 % 2 + ++$var1; 
?>
111/260
111.

What will be the output of the following PHP code ?

<?php
class myObject { }
define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT; 
?>
112/260
112.

What is the output of the following code?

<?php
$a = 1;
function calculate() {
   global $a;
   $a += 7;
   $a = $a * 043;
   return --$a;
}
echo $a;
?>
113/260
113.

Which of the following statements explains the difference between print() and echo()?

114/260
114.

Consider the following PHP script:

<?php
$a = 5; 
$b = 4; 
$c = ($a++ * ++$b);  
echo $c;
?>

What will be the output?

115/260
115.

What will be the output of the following PHP script:

<?php
function modifyArray (&$array) 
{
    foreach ($array as &$value)
    {
         $value = $value + 2; 
    } 
    $value = $value + 3; 
 } 
$array = array (1, 2, 3); 
modifyArray($array); 
print_r($array);
?>
116/260
116.

What will be the output of the following PHP code?

<?php
    $total = "25 students";
    $more = 10;
    $total = $total + $more;
    echo "$total";
    ?>
117/260
117.

What would you replace ??????? with, below, to make the string Hello, World! be displayed?

    function myfunction() {
        /* ??????? */
        echo $string;
    }
    myfunction("Hello, World!");
118/260
118.

The ____ operator returns True if either of its operands can be evaluated as True, but not both.

119/260
119.

Which values should be assigned to the variables $a, $b and $c in order for the following script to display the string Hello, World!?

$string = "Hello, World!";
$a      = '';
$b      = '';
$c      = '';
if ($a) {
    if ($b && !$c) {
        echo "Goodbye Cruel World!";
    } else if (!$b && !$c) {
        echo "Nothing here";
    }
} else {
    if (!$b) {
        if (!$a && (!$b && $c)) {
            echo "Hello, World!";
        } else {
            echo "Goodbye World!";
        }
    } else {
        echo "Not quite.";
    }
}
?> 
120/260
120.

Which of the following equivalence operations evaluates to true if the two operands are not of the same data type or do not have the same value?

121/260
121.

What will be the output of the following PHP code ?

<?php
$i = 0;
$j = 0;
if ($i && ($j = $i + 10)) {
    echo "true";
}
echo $j;
?>
122/260
122.

What is the return value of echo statement in PHP?

123/260
123.

Consider the following segment of code:

<?php
    define("STOP_AT", 1024);
        $result = array();
    /* Missing code */
    {
        $result[] = $idx;
    }

    print_r($result);
?> 

What should go in the marked segment to produce the following array output?

Array
{
 [0] => 1
 [1] => 2
 [2] => 4
 [3] => 8
 [4] => 16
 [5] => 32
 [6] => 64
 [7] => 128
 [8] => 256
 [9] => 512
} 
124/260
124.

You run the following script:

<?php
    $a = 6 - 10 % 4;
    echo $a;
?>

What will be the output?

125/260
125.

What will be the output of the following PHP code ?

<?php
define("__LINE__", "PHP is a scripting language");
echo __LINE__;
?>
126/260
126.

PHP is a _____ scripting language based on the _____ engine. It is primarily used to develop dynamic _____ content, although it can be used to generate _____ documents (among others) as well.

127/260
127.

Which of the following gives a string containing PHP script file name in which it is called?

128/260
128.

You run the following script:

<?php
function odd(){
    for($i=1; $i<=50; $i=$i+2)
    {
        echo "$i";
    }
}
echo "The last value of the variable \$i: $i";
?>

What will be the output?

129/260
129.

What will be the output of the following PHP code ?

<?php
    $one = "one";
    $two = "two";
    print($one$two);
?>
130/260
130.

What is the output of the following script?

<?php
    $a = 10;
    $b = 20;
    $c = 4;
    $d = 8;
    $e = 1.0;
    $f = $c + $d * 2;
    $g = $f % 20;
    $h = $b - $a + $c + 2;
    $i = $h << $c;
    $j = $i * $e;
     print $j;
?> 
131/260
131.

Consider the following code:

<?php
    $x=0;
    $i;
    for($i=0;$i<5;$i++)
    {
        $x+=$i;
    }
    print($x);
?>

What will be the value of x?

132/260
132.

Consider the following code:

<?php
    $a;
    for($a=1;$a<=100;$a++)
    {
    if($a==50)
    {
        continue;
    }
    print($a);
    }
?>

What will be the output of the program?

133/260
133.

Which of the following is NOT a strongly typed language?

134/260
134.

The function gc_collect_cycles() is used to do which of the following?

135/260
135.

What will be the output of the following code?

<?php 
    $foo = 'Bob';              
    $bar = &$foo;              
    $bar = "My name is $bar";  
    echo $bar;
    echo $foo;
?>
136/260
136.

What will be the output of the following PHP code?

<?php
$x;
if ($x)
    print "hi" ;
else
    print "how are u";
?>
137/260
137.

What will be the output of the following PHP code ?

<?php
echo 'Hello World';
<html>
Hello world
</html>
?>
138/260
138.

What is the value of $a and $b after the function call?

<?php
    function doSomething( &$arg ) {
        $return = $arg;
        $arg += 1;
        return $return; 
    }
    $a = 3;
    $b = doSomething( $a );
?>
139/260
139.

What will be the output of the following PHP code ?

<?php
if (print "0")
    print "hi" ;
else
    print "how are u";
?>
140/260
140.

What will be the output of the following PHP code ?

<?php
define("GREETING", "PHP is a scripting language");
echo $GREETING;
?>
141/260
141.

You run the following PHP script:

<?php
function calc()
{
    $x=10;
    $b=++$x;
    print($b);
}
calc();
?>

What will be the value of the variable b?

142/260
142.

What will be the output of the following PHP code ?

<?php
$on$e = 1;
$tw$o = 2;
$thre$e = 3;
$fou$r = 4;
echo "$on$e / $tw$o + $thre$e / $fou$r"; 
?>
143/260
143.

What gets printed?

<?php

$RESULT = 11 + 011 + 0x11;

echo "$RESULT";

?>
144/260
144.

You run the following PHP script:

<?php
for($x = 1; $x <= 2; $x++){
      for($y = 1; $y <= 3; $y++){
         if ($x == $y) continue; 
         print("x = $x  y =  $y");
      }
   }
?>

What will be the output? Each correct answer represents a complete solution. Choose all that apply.

145/260
145.

What will be the output of the following PHP code ?

<?php
$color = 'red';
echo "\$color";
?>
146/260
146.

What will be the output of the following PHP code ?

<?php
$a  =  '12345';
echo "qwe$arty";
?>
147/260
147.

What will be the output of the following PHP code ?

<?php
$x=1;
echo $x-- != ++$x;
?>
148/260
148.

You have been given a code snippet as follows:

$somearray = array("hi", "this is a string", "this is a code");

You want to iterate this array and modify the value of each of its elements. Which of the following is the best possible to accomplish the task?

149/260
149.

Which of the following is used to set a constant?

150/260
150.

Which of the following statements is/are FALSE regarding functions in PHP?

151/260
151.

What is the output of the following code:

<?php
function a($a) {
   echo $a . "&";
}
function b($a) {
   echo "-" . $a;
}
$a = "!";
$b = &$a;
echo a(b($b));
?>
152/260
152.

What will be the output if we declare "ob_start()" function in PHP?

153/260
153.

What will be the output of the following PHP code ?

<?php
define("VAR_NAME","test"); 
${VAR_NAME} = "value"; 
echo VAR_NAME;
echo ${VAR_NAME}; 
?>
154/260
154.

What will be the output of the following code -

    $Rent = 250;   
    function Expenses($Other) { 
        $Rent = 250 + $Other; 
        return $Rent; 
    }  
    Expenses(50);   
    echo $Rent;
155/260
155.

What is the output of this script?

<?php
echo 10 <=> 10 << 1;
156/260
156.

Which statement will output $x on the screen?

157/260
157.

Which of the following is a magic constant?

158/260
158.

What should be the correct syntax to write a PHP code?

159/260
159.

What is displayed when the following script is executed?

<?php

 define(myvalue, "10");
 $myarray[10] = "Dog";
 $myarray[] = "Human"; 
$myarray['myvalue'] = "Cat";
 $myarray["Dog"] = "Cat";
 print "The value is: "; print $myarray[myvalue]."\n";

?> 
160/260
160.

What will be the output of the following PHP code ?

<?php
$y = 2;
if (**$y == 4)
{
    echo $y;
}
?>
161/260
161.

What is the output of the following?

<?php
$a = 7;
$b = 4;
function b($a, $b) {
   global $a, $b;
   $a += 7;
   $a++;
   $b += $a;
   return true;
}
echo $b, $a;
?>
162/260
162.

What will the output of this function be?

<?php
$number = 1234.5678;
echo number_format($number, 2, ',', '.') . PHP_EOL;
163/260
163.

What is the difference between the include and require language constructs?

164/260
164.

What will be the output of the following PHP code ?

<?php
$i = 0
while ($i != 3)
{
    print "hi";
    $i++;
}
?>
165/260
165.

What is the output of the following code?

<?php
$x = 1;
function print_conditional() {
   static $x;
   if($x++ == 1)
      echo "many";
   echo "good";
   echo "things";
   return $x;
}
print_conditional();
$x++;
print_conditional();
?>
166/260
166.

What will be the output of the following PHP code ?

<?php
for ($i = 0;$i = -1;$i = 1)
{
    print $i;
    if ($i != 1) 
    break;
}
?>
167/260
167.

What will be the output of the following PHP code ?

<?php
$y = 2;
if (--$y <> ($y != $y++))
{
    echo $y;
}
?>
168/260
168.

What will be the output of the following PHP code ?

<?php
$x = 10;
$y = 4;
$z = 3;
echo $x % $y % $z;
?>
169/260
169.

Which of the following logical operators is an equivalence logical operator?

170/260
170.

What is the length of the hash generated by the crc32() crypto function?

171/260
171.

Mark works as a Web Application Developer for Blue Solutions Inc. He writes the following code:

<?php
    $x =25;
    while($x<10)
    {
        $x--;
    }
    print ($x); 
?>

What will be the output when Mark tries to compile and execute the code?

172/260
172.

Consider the following code:

<?php   
    $a=5;
    $b=12;
    $c=10;
    $d=7;
    $e=($a*$b)+$c*$d/$a;
    print($e);
?>

What will be the output of the above code?

173/260
173.

What is the difference between print() and echo()?

174/260
174.

What is the output of:

<?php
$a = 10;
echo strlen($a) . count($a);
do {
   echo $a . "elephpant ";
   $a++;
} while($a <= 1);
?>
175/260
175.

What is the output of the following code?

<?php
$a = 42 & 05 + 17;
echo $a;
?>
176/260
176.

What is the output from this script?

<?php
$a = true;
$b = false;
$ampBool = $a && $b;
$andBool = $a and $b;
var_dump($ampBool == $andBool);
?>
177/260
177.

What will be the output of the following PHP code ?

<?php
$i=0;
for (1; $i == 1; $i = 2)
    print "In for loop ";
print "After loop\n";
?>
178/260
178.

which one of these variables has illegal name?

179/260
179.

What is the output of the following line of code:

<?php
$a = 4 << 2 + 1;
echo $a;
?>
180/260
180.

What will be the output of the following PHP code ?

<?php
for(++$i; ++$i; ++$i)
{
    print $i;
    if ($i == 4) 
        break;
}
?>
181/260
181.

Consider the following script:

<?php
    echo date("M-d-Y", mktime(0, 0, 0, 12, 32, 1995));
?>

What will be the output of the above script?

182/260
182.

when PHP is running on a command line, what super-global will contain the command line arguments specified?

183/260
183.

What will be the output of the following PHP code ?

<?php
$var1 = 3;
print $var = ++$var;
?>
184/260
184.

Which of the conditional statements is/are supported by PHP?
i) if statements
ii) if-else statements
iii) if-elseif statements
iv) switch statements

185/260
185.

What will be the output of the following PHP code ?

<?php
$user = array("Ashley", "Bale", "Shrek", "Blank");
    for ($x=0; $x < count($user) - 1; $x++) 
    {
        if ($user[$x++] == "Shrek") 
            continue;
        printf ($user[$x]); 
    }
?>
186/260
186.

What will be the output of the following PHP code ?

<?php
$i = 0
do
{
    print "hi";
    $i++;
}
while ($i != 3);
?>
187/260
187.

What is the best way to iterate through the $myarray array, assuming you want to modify the value of each element as you do?

<?php
    $myarray = array ("My String", "Another String", "Hi, Mom!");
?> 
188/260
188.

What will be the output of the following PHP code ?


<?php
$a = 0x6db7;
print $a<<6;
?>
189/260
189.

Which of the following are superglobals in PHP? (choose three)

190/260
190.

You run the following PHP script:

<? 
    echo (int) "Jason 1235"; 
?>

What will be the output?

191/260
191.

What will the following script output?

$array = '0123456789ABCDEFG';
$s = '';
for ($i = 1; $i < 50; $i++) {
    $s .= $array[rand(0,strlen ($array) - 1)];
}
echo $s; 
192/260
192.

What will be the output of the following PHP code ?

<?php
$auth = 1;
$status = 1;
if ($result = (($auth == 1) && ($status != 0)))
{
    print "result is $result";
}
?>
193/260
193.

What will this script output?

<?php
function A() {
    try {
        b();
    } catch (Exception $e) {
        echo "Exception caught in " . __CLASS__;
    }
}
function B() {
    echo 5 / "five";
}
try {
    A();
} catch (Error $e) {
    echo "Error caught in global scope: " . $e->getMessage();
}
194/260
194.

Under what circumstance is it impossible to assign a default value to a parameter while declaring a function?

195/260
195.

What will be the output of the following PHP code ?

<?php
$y = 2;
if ($y-- == ++$y)
{
    echo $y;
}
?>
196/260
196.

What will this script output?

<?php
$a = "Hello";
$B = " world";
ECHO $a . $b;
197/260
197.

What will be the output of the following PHP code ?

<?php
$i = 2;
while (++$i)
{   
    while (--$i > 0)
        print $i;
}
?>
198/260
198.

Consider the following code:

<?php
function modvalue()
{
       $a=20;
       $b=4;
       $c=$a%$b;
       print($c);
} 
modvalue();
?>

What will be the value of the variable c?

199/260
199.

What will be the output of the following PHP code ?

<?php
    echo "This", "was", "a", "bad", "idea";
?>
200/260
200.

Run-time inclusion of a PHP script is performed using the ____ construct, while compile-time inclusion of PHP scripts is performed using the ____ construct.

201/260
201.

Which is the right way of declaring a variable in PHP?
i) $3hello
ii) $_hello
iii) $this
iv) $This

202/260
202.

Which of the following type of variables are special type that only has one value: NULL?

203/260
203.

What will be the output of the following PHP code ?

<?php
    $one = "Hello";
    $two = "World";
    echo "$one"+"$two";
?>
204/260
204.

What will be the output of the following PHP code?

<?php
    $num  = 1;
    $num1 = 2;
    print $num . "+". $num1;
?>
205/260
205.

What will be the output of the following PHP code ?

<?php
$i = 2;
while (++$i)
{   
    while ($i --> 0)
        print $i;
}
?>
206/260
206.

Which of the following is related to APC (Alternative PHP Cache)?

207/260
207.

In which of the following ways does the identity operator === compare two values?

208/260
208.

Which of the following is not valid PHP code?

209/260
209.

What will be the output of the following PHP code ?

<?php
echo "echo "Hello World"";
?>
210/260
210.

What will be the output of the following PHP code ?

<?php
if (print "hi" - 1)
    print "hello"
?>
211/260
211.

What will be the output of the following PHP code ?

<?php
    echo "This","was"|"a","bad"."idea";
?>
212/260
212.

Which of the following are valid constant names? (Choose three)

213/260
213.

Which of the below symbols is a newline character?

214/260
214.

Which of the following are valid PHP variables?

215/260
215.

You run the following PHP script:

<?php
    $num = -123test;
    $newnum = abs( $num );
    print $newnum;
?>

What will be the output?

216/260
216.

What will the code output?

<?php
$a = 0;
$b = $a++;
$a = $a + 1;
echo --$a;
217/260
217.

Which of the following is NOT a magic predefined constant?

218/260
218.

Which of the following operators has the highest precedence order?

219/260
219.

What will this script output?

echo "Apples"<=>"bananas" ? 'foo' : 'bar';
220/260
220.

What will this code output?

    namespace A;
    $closure = function() { echo __NAMESPACE__; };
    namespace B;
    $closure = function() { echo __NAMESPACE__; };
    namespace C;
    $closure();
221/260
221.

What set of value it will give?

$data = "foo:*:1023:1000::/home/foo:/bin/sh"; 
list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data); 
echo $user; echo $pass;
222/260
222.

Consider the following script:

<html>
<head>
<title>
       This is a test script.
</title>
</head>
<body>
<?php
    echo 'This is some sample text';
?>
</body>
</html>

Which of the following tags is used in the php script?

223/260
223.

What is the output of this scrip?

<?php
define('A', 1);
const B = 2;
define('C', [A * A, B * B]);
echo(C[1]);
224/260
224.

Function world() is defined in the namespace 'myapp\utils\hello'. Your code is in namespace 'myapp'.
What is the correct way to import the hello namespace so you can use the world() function?

225/260
225.

Which of the following are NOt case sensitive in php? Choose all that apply.

226/260
226.

What will be the output of the following PHP code ?

<?php
for ($i = 0; $i < 5; $i++)  
{
    for ($j = $i;$j > $i; $i--)
        print $i;
}
?>
227/260
227.

What will be the output of the following PHP code ?

<?php
for ($i = 0; -5 ; $i++)
{
    print"$i";
    if ($i == 3)
        break;
}
?>
228/260
228.

What will be the output of the following PHP code ?

<?php
$a = "hello";
if ($a.length)
    print $a.length;
else
    print "hi";
?>
229/260
229.

Consider the following PHP script:

<?php
function b($a = 4)
{
  $a = $a / 2;
  return $a;
}
$a = 10;
b($a);
echo $a;
?>

What will be the output?

230/260
230.

What will this script output?

<?php
$a = "0";
$c = $b = empty($a);
$d = ++$b + $a;
echo $d;
231/260
231.

What will be the output of the following PHP code ?

<?php
    $one = "one";
    $two = "two";
    print($one==$two);
?>
232/260
232.

You run the following PHP script:

<? 
    $a=20%-8;
    echo $a;
?>
233/260
233.

Which of the following options is/are correct regarding variable scopes in PHP?

234/260
234.

What will be the output of the following PHP code ?

<?php
$x;
if ($x == 0)
    print "hi" ;
else
    print "how are u";
    print "hello"
?>
235/260
235.

Which of the following is NOT a valid PHP comparison operator?

236/260
236.

Fred works as a Web developer in Fastech Inc. He writes the following script:

<?php
    $s = 2;
    switch ($s) {
      case 1:
         print("Fred");
         break;
      case 2:
         print("Fast");
      case 3:
         print("Tech");
      default: print("default");
    }
?>

What will be displayed as output when Fred attempts to run this PHP script?

237/260
237.

What will be the output of the following PHP code ?

<?php
$y = 2;
if (--$y == 2 || $y xor --$y)
{
    echo $y;
}
?>
238/260
238.

What will be the output of the following PHP code ?

<?php
print_r "Hello world"
?>
239/260
239.

What will be the output of the following PHP code ?

<?php
$x = 1;
if ($x = $x&0)
    print $x ;
else
    print "how are u";
?>
240/260
240.

What will be the output of the following PHP code ?

<?php
    define('GREETING_TEST', 'PHP is a scripting language', true);
    echo GREETING_TESt;
    $changing_variable = 'test';
    echo constant('GREETING_' . strtoupper($changing_variable));
?>
241/260
241.

How to use header() function in PHP correctly?

242/260
242.

How does the identity operator === compare two values?

243/260
243.

What is the output of this script?

<?php
$a = 0b0010;
$b = 0b0001;
echo gettype($a & $b);
244/260
244.

Which of the following is used to convert all applicable characters to HTML entities?

245/260
245.

What will the output of the following code be?

<?php
$a = range(3,9);
foreach ($a as $b) {
   switch($b) {
      case 3:
      $b = 7;
      case 7:
      $b = 3;
      default:
      // do nothing
   }
}
echo implode('-',$a);
?>
246/260
246.

What will be the output of the following PHP code ?

<?php
$i = 10;
$j = 0;
if ($i || ($j = $i + 10)) {
    echo "true";
}
echo $j;
?>
247/260
247.

What will be the output of the following PHP code ?

<?php
$a = 10;
if (1) 
    print "all";
else 
    print "some"
else 
    print "none";
?>
248/260
248.

Consider the following code:

<?php
function add()
{
       $x=10;
       $y=5;
       $x+=$y;
}
?>

What will be the value of x and y?

249/260
249.

What will be the output of the following PHP code ?

<?php
$a = 12;
--$a;
echo $a++;
?>
250/260
250.

Which of the following is a valid namespace operator in PHP?

251/260
251.

What will be the output of the following PHP code ?

<?php
for ($count = 1; $count < 20; $count++);
    print $count;
?>
252/260
252.

What will be the output of the following PHP code ?

<?php
$x = 1;
if ($x--)
    print "hi"
    $x--;
else
    print "hello"
?>
253/260
253.

What does PHP stand for?
i) Personal Home Page
ii) Hypertext Preprocessor
iii) Pretext Hypertext Processor
iv) Preprocessor Home Page

254/260
254.

What will be the output of the following PHP code ?

<?php
$a = 1;
if ($a--)
    print "True";
if ($a++)
    print "False"; 
?>
255/260
255.

What is the output of this script?

<?php
$a = 3;
echo $a >> 1;
256/260
256.

You work as a Web Developer for Remote Inc. What will be the output when you try to run the script below?

<?php
    $b = false;
    if($b = true)
      print("true");
    else
      print("false");
?>
257/260
257.

Which of the below statements is equivalent to $add += $add ?

258/260
258.

what is the name of the error level constant that is used to designate PHP code that will not work in future versions?

259/260
259.

Which of the following will you use to iterate a PHP associative array?

260/260
260.

Which of the following PHP variable names is not a valid variable name?