PHP Language | 10 Minute‐Test 15


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 one of the following functions is used to determine object type?

A.
obj_type()
B.
type()
C.
is_a()
D.
is_obj()

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The is_a() function returns true if object belongs to a class type or if it belongs to a class that is a child of that class. Or else false is returned.

2.

If one intends to create a model that will be assumed by a number of closely related objects, which class must be used?

A.
Normal class
B.
Static class
C.
Abstract class
D.
Interface

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

3.

Which version introduced the function error_get_last()?

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

This function returns an associative array consisting of the type, message, file, and line of the last occurring error.

4.

You can extend the exception base class, but you cannot override any of the preceding methods because the are declared as..

A.
protected
B.
final
C.
static
D.
private

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Marking a method as final prevents it from being overridden by a subclass.

5.

What will be the output of the following PHP code?

    <?php

    $var=300;

    $int_options = array("options"=>array ("min_range"=>0, "max_range"=>256));

    if (!filter_var($var, FILTER_VALIDATE_INT, $int_options))

        echo("Integer is not valid");

    else

        echo("Integer is valid");

    ?>

A.
No output is returned
B.
Integer is not valid
C.
Integer is valid
D.
Error

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Since the integer is “300” it is not in the specified range, and the output of the code above will be: “Integer is not valid”.

6.

POSIX implementation was deprecated in which version of PHP?

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None

7.

What will be the output of the following PHP code?

    <?php

    echo str_pad("Salad", 5)." is good.";

    ?>

A.
SaladSaladSaladSaladSalad is good
B.
is good SaladSaladSaladSaladSalad
C.
is good Salad
D.
Salad is good

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The str_pad() function pads a string with a specified number of characters.

8.

Which one of the following function operates similarly to fgets(), except that it also strips any HTML and PHP tags form the input?

A.
fgetsh()
B.
fgetsp()
C.
fgetsa()
D.
fgetss()

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None

9.

Which one of the following function is useful for producing a timestamp based on a given date and time.

A.
time()
B.
mktime()
C.
mrtime()
D.
mtime()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

10.

Which of the following statements can be used to set the time zone in individual scripts?

A.
date_set_timezone(‘Europe/London’);
B.
date_default_timezone_set(‘Europe/London’);
C.
date_set_default_timezone(‘Europe/London’);
D.
date_default_timezone(‘Europe/London’);
Submit your test now to view the Results and Statistics with answer explanation.