PHP Language | 10 Minute Test


Instruction

  • Total number of questions : 10.
  • Time alloted : 10 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

Which of the below symbols is a newline character?

A.
\r
B.
\n
C.
/n
D.
/r

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

PHP treats \n as newline character.

2.

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

A.
Both i) and iii)
B.
Both ii) and iv)
C.
Only ii)
D.
Both i) and ii)

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

PHP previously stood for Personal Home Page now stands for Hypertext Preprocessor.

3.

Which version of PHP introduced Try/catch Exception?

A.
PHP 4
B.
PHP 5
C.
PHP 5.3
D.
PHP 6

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Version 5 added support for Exception Handling.

4.

What will be the output of the following code?

<?php

    $foo = 'Bob';             

    $bar = &$foo;             

    $bar = "My name is $bar"; 

    echo $bar;

    echo $foo;

?>

A.
Error
B.
My name is BobBob
C.
My name is BobMy name is Bob
D.
My name is Bob Bob

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The $bar = &$foo; line will reference $foo via $bar.

5.

Which statement will output $x on the screen?

A.
echo “\$x‿;
B.
echo “$$x‿;
C.
echo “/$x‿;
D.
echo “$x;‿;

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

A backslash is used so that the dollar sign is treated as a normal string character rather than prompt PHP to treat $x as a variable. The backslash used in this manner is known as escape character.

6.

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

A.
Only i)
B.
i), ii) and iv)
C.
ii), iii) and iv)
D.
All of the mentioned.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

7.

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

A.
12
B.
1
C.
Error
D.
5

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

?: is known as ternary operator. If condition is true then the part just after the ? is executed else the part after : .

8.

Who is the father of PHP?

A.
Rasmus Lerdorf
B.
Willam Makepiece
C.
Drek Kolkevi
D.
List Barely

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

9.

What will be the output of the following PHP code?

<?php

    function a()

    {

        function b()

        {

            echo 'I am b';

  }

        echo 'I am a';

    }

    a();

    a();

    ?>

A.
I am b
B.
I am bI am a
C.
Error
D.
I am a Error

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

This will be the output- I am a Fatal error: Cannot redeclare b()

10.

Which one of the following PHP functions can be used to find files?

A.
glob()
B.
file()
C.
fold()
D.
get_file()

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Here is an example-
// get all php files AND txt files
$files = glob(‘*.{php,txt}’, GLOB_BRACE);
print_r($files);
/* output looks like:
Array
(
[0] => phptest.php
[1] => pi.php
[2] => post_output.php
.
.
.
)


Feedback:

Submit your test now to view the Results and Statistics with answer explanation.