adplus-dvertising

Welcome to the Arrays and Functions in PHP MCQs Page

Dive deep into the fascinating world of Arrays and Functions in PHP with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Arrays and Functions in PHP, a crucial aspect of PHP. In this section, you will encounter a diverse range of MCQs that cover various aspects of Arrays and Functions in PHP, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within PHP.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Arrays and Functions in PHP. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of PHP.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Arrays and Functions in PHP. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Arrays and Functions in PHP MCQs | Page 9 of 15

Q81.
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();
    ?>
Discuss
Answer: (c).Error
Q82.
What will be the output of the following PHP code?
<?php
    $op2 = "blabla";
    function foo($op1)
    {
        echo $op1;
        echo $op2;
    }
    foo("hello");
    ?>
Discuss
Answer: (c).hello
Q83.
A function in PHP which starts with __ (double underscore) is know as..
Discuss
Answer: (a).Magic Function
Q84.
What will be the output of the following PHP code?
<?php
    function foo($msg)
    {
        echo "$msg";
    }
    $var1 = "foo";
    $var1("will this work");
    ?>
Discuss
Answer: (d).Will this work
Q85.
PHP’s numerically indexed array begin with position ___________

a.

1

b.

2

c.

0

d.

-1

Discuss
Answer: (c).0
Q86.
Which of the following are correct ways of creating an array?

i) state[0] = “karnataka”;
ii) $state[] = array(“karnataka”);
iii) $state[0] = “karnataka”;
iv) $state = array(“karnataka”);
Discuss
Answer: (a).iii) and iv)
Q87.
What will be the output of the following php code?
<?php
    $states = array("karnataka" => array
    ( "population" => "11,35,000", "capital" => "Bangalore"),
    "Tamil Nadu" => array( "population" => "17,90,000",
    "capital" => "Chennai") );
    echo $states["karnataka"]["population"];
    ?>
Discuss
Answer: (b).11,35,000
Q88.
Which function will return true if a variable is an array or false if it is not?
Discuss
Answer: (b).is_array()
Q89.
Which in-built function will add a value to the end of an array?
Discuss
Answer: (d).array_push()
Q90.
What will be the output of the following PHP code?
<?php
    $state = array ("Karnataka", "Goa", "Tamil Nadu",
    "Andhra Pradesh");
    echo (array_search ("Tamil Nadu", $state) );
    ?>
Discuss
Answer: (d).2

Suggested Topics

Are you eager to expand your knowledge beyond PHP? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!