PHP Language | 10 Minute‐Test 13


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 version of PHP introduced the instanceof keyword?

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Using instanceof keyword we can determine whether an object is an instance of a class. $manager = new Employee() … if ($manager instanceof Employee) echo “True”;

2.

The class from which the child class inherits is called..
i) Child class
ii) Parent class
iii) Super class
iv) Base class

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

3.

Which character do the error_reporting directive use to represent the logical operator NOT?

A.
/
B.
!
C.
~
D.
^

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The twidle (~) character is used to represent the logical operator NOT.

4.

Which of the following statements invoke the exception class?

A.
throws new Exception();
B.
throw new Exception();
C.
new Exception();
D.
new throws Exception();

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

5.

What will be the output of the following PHP code?

    <?php

    $num = "123";

    if (!filter_var($num, FILTER_VALIDATE_INT))

        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 C

Explanation:

filter_var() – Filters a single variable with a specified filter.

6.

How many functions does PHP offer for searching strings using POSIX style regular expression?

A.
7
B.
8
C.
9
D.
10

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

ereg(), ereg_replace(), eregi(), eregi_replace(), split(), spliti(), and sql_regcase() are the functions offered.

7.

Which one of the following functions will convert a string to all uppercase?

A.
strtoupper()
B.
uppercase()
C.
str_uppercase()
D.
struppercase()

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Its prototype follows string strtoupper(string str).

8.

Which one of the following function is capable of reading a file into a string variable?

A.
file_contents()
B.
file_get_contents()
C.
file_content()
D.
file_get_content()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

9.

If the format is F then which one of the following will be returned?

A.
Complete text representation of month
B.
Day of month, with leading zero
C.
Daylight saving time
D.
Day of month, without zeros

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Day of month, with leading zero is represented by D; Daylight saving time by I; Day of month, without zeros by j.

10.

Which of the following is the right way to use the DateTime class?

A.
$date = get_Class(DateTime);
B.
$date = class DateTime;
C.
$date = new DateTime();
D.
$date = new class DateTime();
Submit your test now to view the Results and Statistics with answer explanation.