Web Programming (3160713) MCQs

MCQs of Server Side Programmingwith PHP

Showing 11 to 20 out of 49 Questions
11.
How to define a function in PHP?
(a) function {function body}
(b) data type functionName(parameters) {function body}
(c) functionName(parameters) {function body}
(d) function functionName(parameters) {function body}
Answer:

Option (d)

12.
What will be the output of the following PHP code?
<?php
    function calc($price, $tax="")
    {
        $total = $price + ($price * $tax);
        echo "$total"; 
    }
    calc(42); 
    ?> 
(a) Error
(b) 0
(c) 42
(d) 84
Answer:

Option (c)

13.
What will be the output of the following PHP code?
<?php
    function a()
    {
        function b()
        {
            echo 'I am b';
  }
        echo 'I am a';
    }
    a();
    ?> 
(a) I am a
(b) I am bI am a
(c) Error
(d) I am a Error
Answer:

Option (a)

14.
What will be the output of the following PHP code?
<?php
    function a()
    {
        function b()
        {
            echo 'I am b';
  }
        echo 'I am a';
    }
    a();
    b();
    ?> 
(a) I am a
(b) I am bI am a
(c) Error
(d) I am aI am B
Answer:

Option (d)

15.
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 a
(b) I am bI am a
(c) Error
(d) I am aI am B
Answer:

Option (c)

16.
What will be the output of the following PHP code?
<?php
    function a()
    {
        function b()
        {
            echo 'I am b';
  }
        echo 'I am a';
    }
    a();
    a();
    ?> 
(a) I am a
(b) I am a Error
(c) Error
(d) I am aI am B
Answer:

Option (b)

17.
What will be the output of the following PHP code?
  <?php
    $op2 = "blabla";
    function foo($op1)
    {
        echo $op1;
        echo $op2;
    }
    foo("hello");
    ?> 
(a) helloblabla
(b) hello with Error
(c) hello with notice
(d) helloblablablabla
Answer:

Option (b)

18.
A function in PHP which starts with __ (double underscore) is known as __________
(a) Magic Function
(b) Inbuilt Function
(c) Default Function
(d) User Defined Function
Answer:

Option (a)

19.
PHP’s numerically indexed array begin with position ___________
(a) 1
(b) 0
(c) 2
(d) -1
Answer:

Option (b)

20.
Which of the following are correct ways of creating an one dimensional array?
i) state[0] = "gujarat";
ii) $state[] = array("gujarat");
iii) $state[0] = "gujarat";
iv)  $state = array("gujarat"); 
(a) iii) and iv)
(b) ii) and iii)
(c) Only i)
(d) ii), iii) and iv)
Answer:

Option (a)

Showing 11 to 20 out of 49 Questions