PHP Language | 30 Minute‐Test 7


Instruction

  • Total number of questions : 30.
  • Time alloted : 30 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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

11.

Which method scope prevents a method from being overridden by a subclass?

A.
Abstract
B.
Protected
C.
Final
D.
Static

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

12.

Which of the following advanced OOP features is/are not supported by PHP?
i) Method overloading
ii) Multiple Inheritance
iii) Namespaces
iv) Object Cloning

A.
All of the mentioned
B.
None of the mentioned
C.
i) and ii)
D.
iii) and iv)

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The advanced OOP features are: Object cloning, Inheritance, Interfaces, Abstract classes, and Namespaces.

13.

How many error levels are available in PHP?

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

14.

Which version of PHP was added with Exception handling?

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Exception handling was added to PHP with the version 5 release, and further enhanced with version 5.3.

15.

Which of the following is/are an external data?
i) Cookies
ii) Input data from a form
iii) Server Variables
iv) Web services data

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None

16.

PHP has long supported two regular expression implementations known as ___ and ___.
i) Perl
ii) PEAR
iii) Pearl
iv) POSIX

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

none

17.

How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The functions are preg_filter(), preg_grep(), preg_match(), preg_match_all(), preg_quote(), preg_replace(), preg_replace_callback(), and preg_split().

18.

The filesize() function returns the file size in ___.

A.
bits
B.
bytes
C.
kilobytes
D.
gigabytes

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

19.

What will be the output of the following PHP code?

    <?php

    echo (checkdate(4,31,2010) ? 'Valid' : 'Invalid');

    ?>

A.
TRUE
B.
FALSE
C.
Valid
D.
Invalid

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

April has 30 days and the above date is 31 therefore Invalid is returned.

20.

How many methods does the DateTime class have?

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The DateTime class has nine methods, all of which are public.

21.

Which two predefined variables are used to retrieve information from forms?

A.
$GET & $SET
B.
$_GET & $_SET
C.
$__GET & $__SET
D.
GET & SET

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

22.

How many predefined variables does PHP use to authenticate a user?

A.
1
B.
2
C.
3
D.
4

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

23.

Which directive determines whether PHP scripts on the server can accept file uploads?

A.
file_uploads
B.
file_upload
C.
file_input
D.
file_intake

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

By default its value is on.

24.

What is the full form of DNS?

A.
Digital Network System
B.
Domain Network System
C.
Digital Name System
D.
Domain Name System

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The Domain Name System(DNS) is what allows you to use domain names(e.g., example.com) in place of the corresponding IP address, such as 192.0.10.10.

25.

Which one of the following is the very first task executed by a session enabled page?

A.
Delete the previous session
B.
Start a new session
C.
Check whether a valid session exists
D.
Handle the session

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None

26.

Which function is used to erase all session variables stored in the current session?

A.
session_destroy()
B.
session_change()
C.
session_remove()
D.
session_unset()

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

This will not completely remove the session from the storage mechanism. If you want to completely destroy the session, you need to use the function session_destroy().

27.

Which one of the following statements should be used to disable just the fopen(), and file() functions?

A.
disable_functions = fopen(),file()
B.
disable_functions = fopen,file
C.
functions_disable = fopen(),file()
D.
functions_disable = fopen,file

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

You can set disable_functions equal to a comma-delimited list of function names that you want to disable.

28.

What will be the output of the following PHP code?

    <?php

    $number = array(0,1,two,three,four,5);

    $num = preg_grep("/[0-5]/", $number);

    print_r($num);

    ?>

A.
Array([0]=>0 [1]=>1 [2]=>two [3]=>three [4]=>four [5]=>5)
B.
Array([2]=>two [3]=>three [4]=>four)
C.
Array([1]=> 1)
D.
Array([0]=>0 [1]=>1 [5]=>5)

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The preg_grep function is used to search an array for specific patterns and then return a new array based on that filtering.

29.

Which one of the following databases has PHP supported almost since the beginning?

A.
Oracle Database
B.
SQL
C.
SQL+
D.
MySQL

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None

30.

Which one of the following statements should be used to include a file?

A.
#include ‘filename’;
B.
include ‘filename’;
C.
@include ‘filename’;
D.
#include ;

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

Submit your test now to view the Results and Statistics with answer explanation.