Home
Current Affairs January 2024

What is the correct answer?

4

What will be the output of the following PHP code?
 <?php   $fname = array(Peter, Ben, Joe);
$age = array(35, 37, 43);
$c = array_combine($fname, $age);
print_r($c);
?>

A.

Array ( Peter Ben Joe )

B.

Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )

C.

Array ( 35 37 43 )

D.

Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )

Correct Answer :

B.

Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )


The array_combine() function creates an array by using the elements from one keys array and one values array.

Related Questions

What is the correct answer?

4

What will be the output of the following PHP code?
 <?php  $a1 = array(a=>red, b=>green, c=>blue, d=>yellow);
$a2 = array(e=>red, f=>green, g=>blue);
$result = array_diff($a1, $a2);
print_r($result);
?>

A.

Array ( [d] => yellow )

B.

Array ( [c] => blue )

C.

Array ( [a] => red )

D.

Array ( [e] => yellow )

What is the correct answer?

4

What will be the output of the following PHP code?
 <?php  $a = array(a=>red, b=>green, c=>blue);
echo array_shift($a);
print_r ($a);
?>

A.

green

B.

red

C.

redArray( [c] => green [c] => blue )

D.

redArray( [b] => green [c] => blue )

What is the correct answer?

4

Which one of the following format parameter can be used to identify timezone?

A. T

B. N

C. E

D. I

What is the correct answer?

4

If the format is F then which one of the following will be returned?

A. Complete text representation of month

B. Day of month, with leading zero

C. Daylight saving time

D. Day of month, without zeros

What is the correct answer?

4

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)


What is the correct answer?

4

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
;
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 )

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  $color1 = red;
$color2 = 1;
echo $color1 + $color2;
?>

A. red1

B. red 1

C. 0

D. 1

What is the correct answer?

4

A PHP script should start with ___ and end with ___:


A.

< php >


B.

< ? php ?>


C.

<?php ?>


D.

<% %>


What is the correct answer?

4

If the directive session.cookie_lifetime is set to 3600, the cookie will live until..

A. 3600 sec

B. 3600 min

C. 3600 hrs

D. the browser is restarted

What is the correct answer?

4

Which directive determines how the session information will be stored?

A.

save_data

B.

session.save

C.

session.save_data

D.

session.save_handler

What is the correct answer?

4

Which of the following must be installed on your computer so as to run PHP script?
i) Adobe Dreamweaver
ii) PHP
iii) Apache
iv) IIS


A.

All of the mentioned.


B.

Only ii)


C.

ii) and iii)


D.

ii), iii) and iv)


What is the correct answer?

4

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

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  define(GREETING, PHP is a scripting language);
echo $GREETING;
?>

A. $GREETING

B. no output

C. PHP is a scripting language

D. GREETING

What is the correct answer?

4

Which one of the following function is useful for producing a timestamp based on a given date and time.

A.

time()

B.

mktime()

C.

mrtime()

D.

mtime()

What is the correct answer?

4

What will be the output of the following PHP code?
 <?php   $fname = array(Peter, Ben, Joe);
$age = array(35, 37, 43);
$c = array_combine($fname, $age);
print_r($c);
?>

A.

Array ( Peter Ben Joe )

B.

Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )

C.

Array ( 35 37 43 )

D.

Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  $color1 = red;
$color2 = green;
echo $color1 + $color2;
?>

A. redgreen

B. red green

C. 0

D. error

What is the correct answer?

4

What will be the output of the following code?



<?php
$foo = 'Bob';
$bar = &$foo;
$bar = "My name is $bar";
echo $bar;
echo $foo;
?>

A.

Error


B.

My name is BobBob


C.

My name is BobMy name is Bob


D.

My name is Bob Bob


What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  /*echo Hello world;
*/ ?>

A. Hello world

B. Nothing

C. Error

D.

/* Hello world */

What is the correct answer?

4

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)


What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  $i = 5;
while (--$i > 0 || ++$i){ print $i;
} ?>

A. 54321111111….infinitely

B. 555555555…infinitely

C. 54321

D. 5

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  $color = red;
echo $color . red ;
?>

A. red red

B. red

C. error

D. nothing

What is the correct answer?

4

Neglecting to set which of the following cookie will result in the cookies 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

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  $color1 = red;
$color2 = 1;
$color3 = greyecho $color1 + $color2 . $color3;
?>

A. 1grey

B. grey

C. 0

D. red1grey

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  class myObject { }define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT;
?>

A. test

B. error

C. myObject::CONSTANT

D. no output

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  define('IF', 42);
echo IF: , IF;
?>

A. IF:42

B. No output

C. IF:

D. ERROR

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  define(__LINE__, PHP is a scripting language);
echo __LINE__;
?>

A. PHP is a scripting language

B. __LINE__

C. 2

D. ERROR

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  $i = ;
while ($i = 10){ print hi;
}print hello;
?>

A. hello

B. infinite loop

C. hihello

D. error

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  $color = red;
$color = green;
echo $color;
?>

A. red

B. green

C. red green

D. error

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  $i = 0;
while ($i = 10){ print hi;
}print hello;
?>

A. hello

B. infinite loop

C. hihello

D. error

What is the correct answer?

4

What will be the output of the following PHP code?
 <?php  $cars = array(Volvo, BMW, Toyota, Honda, Mercedes, Opel);
print_r(array_chunk($cars, 2));
?>

A.

Array ( [0] => Array ( [1] => Volvo [2] => BMW ) [1] => Array ( [1] => Toyota [2] => Honda ) [2] => Array ( [1] => Mercedes [2] => Opel ) )

B.

Array ( [1] => Array ( [1] => Volvo [2] => BMW ) [2] => Array ( [1] => Toyota [2] => Honda ) [3] => Array ( [1] => Mercedes [2] => Opel ) )

C.

Array ( [0] => Array ( [0] => Volvo [1] => Volvo ) [1] => Array ( [0] => BMW [1] => BMW ) [2] => Array ( [0] => Toyota [1] => Toyota ) )

D.

Array ( [0] => Array ( [0] => Volvo [1] => BMW ) [1] => Array ( [0] => Toyota [1] => Honda ) [2] => Array ( [0] => Mercedes [1] => Opel ) )