PHP Language | 10 Minute‐Test 1


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.

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.

2.

Which of following variables can be assigned a value to it?
i) $3hello
ii) $_hello
iii) $this
iv) $This

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

A variable can’t start with a number. Also $this is a special variable that can’t be assigned, but $This can be assigned.

3.

What will be the output of the following PHP code?

    <?php

    $a = 5;

    $b = 5;

    echo ($a === $b);

    ?>

A.
5 === 5
B.
Error
C.
1
D.
False

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

=== operator returns 1 if $a and $b are equivalent and $a and $b have the same type.

4.

Which one of the following is the right way of defining a function in PHP?

A.
function { function body }
B.
data type functionName(parameters) { function body }
C.
functionName(parameters) { function body }
D.
function fumctionName(parameters) { function body }

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

5.

Which one of the following PHP functions can be used to build a function that accepts any number of arguments?

A.
func_get_argv()
B.
func_get_args()
C.
get_argv()
D.
get_argc()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Here is an example-
function foo()
{
$args = func_get_args();
foreach ($args as $k => $v)
{
echo “arg”.($k+1).”: $v\n”;
}
}
foo();
/* will print nothing */
foo(“Hello”);
/* will print Hello */
foo(“Hello”,”World”,”Bye”);
/* will print Hello World Bye */

6.

PHP’s numerically indexed array begin with position __.

A.
1
B.
2
C.
0
D.
-1

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Like many programming languages, the first element of an array has an index value of 0.

7.

What will be the output of the following PHP code ?

<?php

$age = array("Harry" => "21", "Ron" => "23","Malfoy" => "21");

array_change_key_case($age, CASE_UPPER);

array_pop($age);

print_r($age);

?>

A.
Array ( [Harry] => 21 [Ron] => 23 [Malfoy] => 21 )
B.
Array ( [HARRY] => 21 [RON] => 23 [MALFOY] => 21 )
C.
Array ( [HARRY] => 21 [RON] => 23 )
D.
Array ( [Harry] => 21 [Ron] => 23 )

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The array_change_key_case() function changes all keys in an array to lowercase or uppercase and arry_pop() removes last element

8.

What will be the output of the following PHP code?

<?php

$cars = array("Volvo", "BMW", "Toyota");

echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";

?>

A.
I like Volvo BMW and Toyota.
B.
I like Volvo, BMW and Toyota.
C.
I like Volvo, BMW and Toyota
D.
I like. Volvo.,. BMW. and Toyota .

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The array() function is used to create an array.

9.

What will be the output of the following PHP code?

    <?php

    $fruits = array ("mango", "apple", "pear", "peach");

    $fruits = array_flip($fruits);

    echo ($fruits[0]);

    ?>

A.
mango
B.
Error
C.
peach
D.
0

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

As we are flipping the values, $fruits[“mango”] = 0, $fruits[“apple”] = 1 and so on.

10.

The practice of separating the user from the true inner workings of an application through well-known interfaces is known as..

A.
Polymorphism
B.
Inheritance
C.
Encapsulation
D.
Abstraction
Submit your test now to view the Results and Statistics with answer explanation.