PHP Language | 10 Minute‐Test 14


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 whether a class exists?

A.
exist()
B.
exist_class()
C.
class_exist()
D.
__exist()

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The class_exist() function returns true or false according to whether the class exists within the currently executing script content.

2.

Which of the following is/are true for an abstract class?
i) A class is declared abstract by prefacing the definition with the word abstract.
ii) A class is declare abstract by using the keyword implements.
iii) It is a class that really isn’t supposed to ever be instantiated but instead serves as a base class.
iv) Attempting to instantiate an abstract class results in an error.

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

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

3.

Say you want to report error concerned about fatal run-time, fatal compile-time error and core error which statement would you use?

A.
error_reporting = E_ALL
B.
error_reporting = E_ERROR | E_PARSE | E_CORE_ERROR
C.
error_reporting = E_ERROR | E_COMPILE_WARNING | E_CORE_ERROR
D.
error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

4.

Which one of the following is the right description for the method getMessage() ?

A.
Returns the message if it is passed to the constructor.
B.
Returns the message if it is passed to the class.
C.
Returns the message if it is passed to the file.
D.
Returns the message if it is passed to the object.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None

5.

Which one of the following does not describe a validating filter?

A.
Are used to allow or disallow specified characters in a string
B.
Are used to validate user input
C.
Strict format rules
D.
Returns the expected type on success or FALSE on failure

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Option a) describes Sanitizing filters.

6.

What will be the output of the following PHP code?

    <?php

    $username = "jasoN";

    if (ereg("([^a-z])",$username))

        echo "Username must be all lowercase!";

    else

        echo "Username is all lowercase!";

    ?>

A.
Error
B.
Username must be all lowercase!
C.
Username is all lowercase!
D.
No Output is returned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Because the provided username is not all lowercase, ereg() will not return FALSE (instead returning the length of the matched string, which PHP will treat as TRUE), causing the message to output.

7.

What will be the output of the following PHP code?

    <?php

    $title = "O'malley wins the heavyweight championship!";

    echo ucwords($title);

    ?>

A.
O’Malley Wins The Heavyweight Championship!
B.
O’malley Wins The Heavyweight Championship!
C.
O’Malley wins the heavyweight championship!
D.
o’malley wins the heavyweight championship!

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The ucwords() function capitalizes the first letter of each word in a string. Its prototype follows: string ucwords(string str).

8.

Which one of the following function is capable of reading a specific number of characters form a file?

A.
fgets()
B.
fget()
C.
fileget()
D.
filegets()

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Its prototype is string fgets(resource handle [, int length]). If the optional length parameter is omitted, 1024 character is assumed.

9.

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

    <?php

    echo "Today is ".date("F d, Y")

    ?>

A.
Today is 22 June, 2013
B.
Today is 22-06-2013
C.
Today is 06-22-2013
D.
Today is June 22, 2013

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

F is the parameter for complete text representation of month, d for day of month, and Y for 4 digit representation of year.

10.

What will be the output of the following PHP code if date is 24/02/2008?

    <?php

    $date = new DateTime();

    echo $date->format('l,F,js,Y')

    ?>

A.
Sunday, February 24th 2008
B.
Sunday, 02 24 2008
C.
Sunday, 24 02 2008
D.
Sunday, 24th February 2008
Submit your test now to view the Results and Statistics with answer explanation.