PHP Language | 10 Minute‐Test 17


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.

In the PHP code given below, what is/are the properties?

    <?php

    class Example

    {

        public $name;

        function Sample()

        {

            echo "This is an example";

        }

    }

    ?>

A.
echo “This is an example”;
B.
public $name;
C.
class Example
D.
function sample()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Yes they are nothing but variables.

2.

Which method is used to tweak an object’s cloning behavior?

A.
clone()
B.
__clone()
C.
_clone
D.
object_clone()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

3.

Which function initializes the constants necessary for using the openlog(), clodelog(), and syslog() functions?

A.
define_variable()
B.
define_log_variable()
C.
log_variable()
D.
define_syslog_variable()

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

If you’re running PHP version 5.2.X or older, you need to execute this function before using any of the following logging functions.

4.

How many predefined exceptions does SPL provide access to?

A.
13
B.
14
C.
15
D.
16

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

5.

Which one of the following filter checks if variable of specified type exists?

A.
filter_has_var
B.
filter_var
C.
filter_id
D.
filter_var_array

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None

6.

What will be the output of the following PHP code?

    <?php

    $text = "this is\tsome text that\nwe might like to parse.";

    print_r(split("[\n\t]",$text));

    ?>

A.
this is some text that we might like to parse.
B.
Array ( [0] => some text that [1] => we might like to parse. )
C.
Array ( [0] => this is [1] => some text that [2] => we might like to parse. )
D.
[0] => this is [1] => some text that [2] => we might like to parse.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The split() function divides a string into various elements, with the boundaries of each element based on the occurrence of a defined pattern within the string.

7.

What will be the output of the following PHP code?

    <?php

    $author = "nachiketh@example.com";

    $author = str_replace("a","@",$author);

    echo "Contact the author of this article at $author.";

    ?>

A.
Contact the author of this article at nachiketh@ex@mple.com
B.
Cont@ct the @uthor of this @rticle @t n@chiketh@ex@mple.com
C.
Contact the author of this article at n@chiketh@ex@mple.com
D.
Error

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The str_replace() function case sensitively replaces all instances of a string with another.

8.

Which function sets the file filename’s last-modified and last-accessed times?

A.
sets()
B.
set()
C.
touch()
D.
touched()

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Its prototype is int touch(string filename [, int time [, int atime]]). It returns TRUE on success or FALSE on error.

9.

What will be the output of the following PHP code? If say date is 22/06/2013.

    <?php

    printf( date("t") )

    ?>

A.
30
B.
22
C.
JUNE
D.
2013

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The t parameter is used to determine the number of days in the current month.

10.

Among the four PHP DateTimeZone classes given below how many are nonstatic?
i) _construct()
ii) getName()
iii) getOffset()
iv) getTransitions()

A.
1
B.
2
C.
3
D.
4
Submit your test now to view the Results and Statistics with answer explanation.