PHP Language | 30 Minute‐Test 4


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.

Which of the following php statement/statements will store 111 in variable num?
i) int $num = 111;
ii) int mum = 111;
iii) $num = 111;
iv) 111 = $num;

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

You need not specify the datatype in php.

2.

Which of the below statements is equivalent to $add += $add ?

A.
$add = $add
B.
$add = $add +$add
C.
$add = $add + 1
D.
$add = $add + $add + 1

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

a += b is an addition assignment whose outcome is a = a + b. Same can be done with subtraction,multiplication,division etc.

3.

What will be the output of the following PHP code?

    <?php

    $user = array("Ashley", "Bale", "Shrek", "Blank");

    for ($x=0; $x < count($user); $x++)

       {

        if ($user[$x] == "Shrek") continue;

            printf ($user[$x]);

    }

    ?>

A.
AshleyBale
B.
AshleyBaleBlank
C.
ShrekBlank
D.
Shrek

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The continue statement causes execution of the current loop iteration to end and commence at the beginning of the next iteration.

4.

What will be the output of the following PHP code?

    <?php

    function a()

      {

        function b()

        {

            echo 'I am b'; }

        echo 'I am a';

    }

    b();

    a();

    ?>

A.
I am b
B.
I am bI am a
C.
Error.
D.
I am a Error

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

This will be the output- Fatal error: Call to undefined function b(). You cannot call a function which is inside a function without calling the outside function.

5.

What will be the output of the following PHP code?

    <?php

        echo ord("hi");

    ?>

A.
106
B.
103
C.
104
D.
209

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

expl

6.

What will be the output of the following PHP code?

    <?php

    $fruits = array ("apple", "orange", "banana");

    echo (next($fruits));

        echo (next($fruits));

    ?>

A.
orangebanana
B.
appleorange
C.
orangeorange
D.
appleapple

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The next() function returns the array value residing at the position immediately following that of the current array pointer.

7.

What will be the output of the following PHP code ?

<?php

$people = array("Peter", "Susan", "Edmund", "Lucy");

echo pos($people);

?>

A.
Lucy
B.
Peter
C.
Susan
D.
Edmund

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The pos() function returns the value of the current element in an array, and since no operation has been done, the current element is the first element.

8.

What will be the output of the following PHP code?

<?php

$a1 = array_fill(3, 4, "blue");

$b1 = array_fill(0, 1, "red");

print_r($a1);echo "<br>";

print_r($b1);

?>

A.
Array ( [3] => blue [4] => blue)
Array ( [0] => red )
B.
Array ( [4] => blue [5] => blue [6] => blue)
Array ( [0] => red )
C.
Array ( [3] => blue [4] => blue [5] => blue [6] => blue )
Array ()
D.
Array ( [3] => blue [4] => blue [5] => blue [6] => blue )
Array ( [0] => red )

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The array_fill() function fills an array with values.

9.

What will be the output of the following PHP code?

    <?php

    $fruits = array ("apple", "mango", "peach", "pear",    "orange");

    $subset = array_slice ($fruits, 2);

    print_r ($subset);

    ?>

A.
Array ( [0] => peach )
B.
Array ( [0] => apple [1] => mango [2] => peach )
C.
Array ( [0] => apple [1] => mango )
D.
Array ( [0] => peach [1] => pear [2] => orange )

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The array_slice() function returns a section of an array based on a starting and ending offset value.

10.

Which one of the following is the right way to call a class constant, given that the class is mathFunction?

A.
echo PI;
B.
echo mathFunction->PI;
C.
echo mathFunction::PI;
D.
echo mathFunction=PI;

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

11.

Which one of the following keyword is used to inherit our subclass into a superclass?

A.
extends
B.
implements
C.
inherit
D.
include

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

12.

If your object must inherit behavior from a number of sources you must use a/an

A.
Interface
B.
Object
C.
abstract class
D.
static class

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

13.

Which of the following statements causes PHP to disregard repeated error messages that occur within the same file and on the same line?

A.
ignore_repeated_errors
B.
ignore_repeat_error
C.
repeatedly_ignore_error
D.
repeated_error_ignore

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

14.

What does SPL stand for?

A.
Standard PHP Library
B.
Source PHP Library
C.
Standard PHP List
D.
Source PHP List

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The standard PHP library(SPL) extends PHP by offering ready-made solutions to commonplace tasks such as file access, iteration of various sorts etc.

15.

If the input variable is a string like this “http://www.saåånfoøøundry.com/”, the $url variable after the sanitizing will look like

A.
http://www.saåånfoøøundry.com/
B.
http://www.saaanfoooundry.com/
C.
http://www.saånfoøundry.com/
D.
http://www.sanfoundry.com/

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Sanitize is nothing but take away invalid characters so therefore the invalid characters like å and ø will be removed.

16.

POSIX stands for

A.
Portable Operating System Interface for Unix
B.
Portable Operating System Interface for Linux
C.
Portative Operating System Interface for Unix
D.
Portative Operating System Interface for Linux

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None

17.

Which one of the following functions can be used to concatenate array elements to form a single delimited string?

A.
explode()
B.
implode()
C.
concat()
D.
concatenate()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

18.

Which one of the following function outputs the contents of a string variable to the specified resource?

A.
filewrite()
B.
fwrite()
C.
filewrites()
D.
fwrites()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

19.

Which function displays the web page’s most recent modification date?

A.
lastmod()
B.
getlastmod()
C.
last_mod()
D.
get_last_mod()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The getlastmod() function returns the value of the page’s Last Modified header or FALSE in the case of an error.

20.

Among the four PHP DateTimeZone classes given below how many are static?
i) listAbbreviations()
ii) getName()
iii) getOffset()
iv) listIdentifiers()

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

listAbbreviations() and listIdentifiers() are static methods.

21.

Which function is used to remove all HTML tags from a string passed to a form?

A.
remove_tags()
B.
strip_tags()
C.
tags_strip()
D.
tags_remove()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

22.

The authenticationFile.txt, the file which stores username and password should be stored ___ the server document root

A.
Inside
B.
Outside
C.
Within
D.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

If it is not stored outside, the attacker could discover the file through brute force guessing.

23.

If you want to temporarily store uploaded files in the /tmp/phpuploads/ directory, which one of the following statement will you use?

A.
upload_tmp_dir “/tmp/phpuploads/ directory”
B.
upload_dir “/tmp/phpuploads/ directory”
C.
upload_temp_dir “/tmp/phpuploads/ directory”
D.
upload_temp_director “/tmp/phpuploads/ directory”

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None

24.

Which one of the following statements can be used to establish port 80 connection with www.nachi.com?

A.
fsockopen(“www.nachi.com”, 80);
B.
sockopen(80,”www.nachi.com”);
C.
fsockopen(80,”www.nachi.com”);
D.
sockopen(“www.nachi.com”, 80);

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The fsockopen() function establishes a connection to the resource designated by target on port.

25.

Neglecting to set which of the following cookie will result in the cookie’s domain being set to the host name of the server which generated it.

A.
session.domain
B.
session.path
C.
session.cookie_path
D.
session.cookie_domain

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The directive session.cookie_domain determines the domain for which the cookie is valid.

26.

Which function effectively deletes all sessions that have expired?

A.
session_delete()
B.
session_destroy()
C.
session_garbage_collect()
D.
session_expired_delete()

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None

27.

Which directive determines which degree of server details is provided if the ServerSignature directive is enabled?

A.
ServerAddons
B.
ServerExtra
C.
ServerTokens
D.
ServerDetails

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Six options are available: Full, Major, Minimal, Minior, OS, and Prod. If it is set to Full ‘Apache/2.2.11 (Ubuntu) PHP/5.3.2 Server’ will be displayed.

28.

Which one of the following preg PHP functions is used to take a string, and put it in an array?

A.
preg_destroy()
B.
preg_split()
C.
preg_unchain()
D.
preg_divide()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The string is broken up into different values in the array based upon your input.

29.

Which one of the following statements can be used to select the database?

A.
$mysqli=select_db(‘databasename’);
B.
mysqli=select_db(‘databasename’);
C.
mysqli->select_db(‘databasename’);
D.
$mysqli->select_db(‘databasename’);

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None

30.

Which of the following methods is used to execute the statement after the parameters have been bound?

A.
bind_param()
B.
bind_result()
C.
bound_param()
D.
bound_result()

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Once the statement has been prepared, it needs to be executed. Exactly when it’s executed depends upon whether you want to work with bound parameters or bound results. In the case of bound parameters, you’d execute the statement after the parameters have been bound with the bind_param() method.

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