PHP/PHP%20MCQ%C3%A2%E2%82%AC%E2%80%9C%20Basics Sample Test,Sample questions

Question:
 If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?

1.12

2.1

3.Error

4.5

Posted Date:-2022-02-16 09:32:37


Question:
 What will be the output of the following PHP code?

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

1.3

2.1+2

3. 1.+.2

4.Error

Posted Date:-2022-02-16 08:36:43


Question:
 What will be the output of the following PHP code?

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

1.123

2.111

3.000

4.011

Posted Date:-2022-02-16 09:14:55


Question:
 Which is the right way of declaring a variable in PHP?

i) $3hello
ii) $_hello
iii) $this
iv) $This

1.Only ii)

2.Only iii)

3.ii), iii) and iv)

4. ii) and iv)

Posted Date:-2022-02-16 08:46:44


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

1.$add = $add

2.$add = $add +$add

3. $add = $add + 1

4. $add = $add + $add + 1

Posted Date:-2022-02-16 09:11:32


Question:
 Which of the below symbols is a newline character?

1.

2.

3. /n

4. /r

Posted Date:-2022-02-16 09:18:28


Question:
 Which of the following is/are a PHP code editor?

  

1.Notepad

2.Notepad++

3.Adobe Dreamweaver

4.PDT

Posted Date:-2022-02-16 07:22:51


Question:
 Who is the father of PHP?

1.Rasmus Lerdorf

2.Willam Makepiece

3.Drek Kolkevi

4.List Barely

Posted Date:-2022-02-16 09:35:45


Question:
How should we add a single line comment in our PHP code?

    i) /?
    ii) //
    iii) #
    iv) /* */

1.Only ii)

2.i), iii) and iv)

3.ii), iii) and iv)

4. Both ii) and iv)

Posted Date:-2022-02-16 08:13:26


Question:
PHP files have a default file extension of_______

1..html

2..xml

3..php

4. .ph

Posted Date:-2022-02-16 07:19:51


Question:
What does PHP stand for?

   i) Personal Home Page
   ii) Hypertext Preprocessor
   iii) Pretext Hypertext Processor
   iv) Preprocessor Home Page

1.Both i) and iii)

2.Both ii) and iv)

3.Only ii)

4.Both i) and ii)

Posted Date:-2022-02-16 07:18:52


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

1.< php >

2.< ? php ?>

3.<? ?>

4. <?php ?>

Posted Date:-2022-02-16 07:21:39


Question:
What will be the output of the following PHP code?

    <?php
    $a = "clue";
    $a .= "get";
    echo "$a";
    ?>

1.get

2.true

3.false

4.clueget

Posted Date:-2022-02-16 09:16:04


Question:
What will be the output of the following PHP code?

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

1.5 === 5

2.Error

3.1

4.False

Posted Date:-2022-02-16 09:17:36


Question:
What will be the output of the following PHP code?

    <?php
    $color = "maroon";
    $var = $color[2];
    echo "$var";
    ?>

1.a

2.Error

3.$var

4.R

Posted Date:-2022-02-16 09:08:22


Question:
What will be the output of the following PHP code?

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

1.1

2.Error

3.1234

4.2

Posted Date:-2022-02-16 09:09:29


Question:
What will be the output of the following PHP code?

    <?php
    $team = "arsenal";
    switch ($team) {
    case "manu":
        echo "I love man u";
    case "arsenal":
        echo "I love arsenal";
    case "manc":
        echo "I love manc"; }
    ?>

1. I love arsenal

2.Error

3.I love arsenalI love manc

4. I love arsenalI love mancI love manu

Posted Date:-2022-02-16 09:22:56


Question:
What will be the output of the following PHP code?

    <?php
    $total = "25 students";
    $more = 10;
    $total = $total + $more;
    echo "$total";
    ?>

1.Error

2.35 students

3.35

4.25 students

Posted Date:-2022-02-16 09:10:19


Question:
What will be the output of the following PHP code?

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

1.AshleyBale

2.AshleyBaleBlank

3.ShrekBlank

4.Shrek

Posted Date:-2022-02-16 09:31:48


Question:
What will be the output of the following PHP code?

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

1. Error

2.My name is BobBob

3.My name is BobMy name is Bob

4.My name is Bob Bob

Posted Date:-2022-02-16 08:48:12


Question:
What will be the value of $a and $b after the function call in the following PHP code?

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

1.a is 3 and b is 4

2. a is 4 and b is 3

3.Both are 3

4.Both are 4

Posted Date:-2022-02-16 09:34:26


Question:
Which of the conditional statements is/are supported by PHP?

i) if statements
ii) if-else statements
iii) if-elseif statements
iv) switch statements

1.Only i)

2. i), ii) and iv)

3. ii), iii) and iv)

4.i), ii), iii) and iv)

Posted Date:-2022-02-16 09:19:53


Question:
Which of the following must be installed on your computer so as to run PHP script?

i) Adobe Dreamweaver 
ii) XAMPP
iii) Apache and PHP
iv) IIS

1.i), ii), iii) and iv)

2.Only ii)

3. ii) and iii)

4.ii), iii) and iv)

Posted Date:-2022-02-16 07:23:46


Question:
Which of the following PHP statement/statements will store 111 in variable num?

    i) int $num = 111;
    ii) int mum = 111;
    iii) $num = 111;
    iv) 111 = $num;

1.Both i) and ii)

2.i), ii), iii) and iv)

3.Only iii)

4.Only i)

Posted Date:-2022-02-16 08:19:30


Question:
Which of the following PHP statements will output Hello World on the screen?

i) echo ("Hello World");
ii) print ("Hello World");
iii) printf ("Hello World");
iv) sprintf ("Hello World");

1.i) and ii)

2. i), ii) and iii)

3.i), ii), iii) and iv)

4.i), ii) and iv)

Posted Date:-2022-02-16 09:07:38


Question:
Which statement will output $x on the screen?

1. echo “$x”;

2. echo “$$x”;

3.echo “/$x”;

4.echo “$x;”;

Posted Date:-2022-02-16 09:12:46


Question:
Which statement will output $x on the screen?

1. echo “$x”;

2. echo “$$x”;

3.echo “/$x”;

4.echo “$x;”;

Posted Date:-2022-02-16 09:12:54


Question:
Which version of PHP introduced Try/catch Exception?

1.PHP 4

2.PHP 5

3.PHP 6

4. PHP 5 and later

Posted Date:-2022-02-16 07:24:49


More MCQS

  1. PHP Mcq Set 1
  2. PHP Mcq Set 2
  3. PHP Mcq Set 3
  4. PHP Mcq Set 4
  5. Current affairs mcq php
  6. Current affairs mcq php set 2
  7. Current affairs mcq php set 3
  8. PHP MCQ
  9. PHP MCQ Basics
  10. PHP Mcq Functions
  11. PHP Mcq Arrays
  12. PHP Mcq Basics of Object-Oriented PHP
  13. PHP Mcq Error Handling
  14. PHP Basics Mcq Questions
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!