Home
Current Affairs January 2024

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. red green

B. red

C. green

D. error

Correct Answer :

D. error


It has to be $color1 = red;
and $color2 = green;
therefore the error.

Related Questions

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

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

A. 5

B. 555555555…infinitely

C. 54321

D. error

What is the correct answer?

4

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

A. 1234567891011121314….infinitely

B. 01234567891011121314…infinitely

C. no output

D. error

What is the correct answer?

4

Which of the following is/are a PHP code editor?
i) Notepad
ii) Notepad++
iii) Adobe Dreamweaver
iv) PDT


A.

Only iv)


B.

All of the mentioned.


C.

i), ii) and iii)


D.

Only iii)


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

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

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

A. PHP is a scripting language

B. GREETING
GREEtING

C. GREETING

D. PHP is a scripting language
PHP is a scripting language

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  class Constants{    define('MIN_VALUE', '0.0');
define('MAX_VALUE', '1.0');
public static function getMinValue() { return self::MIN_VALUE;
} public static function getMaxValue() { return self::MAX_VALUE;
}}echo Constants::getMinValue();
echo Constants::getMaxValue();
?>

A. 0.01.0

B. 01

C. No output

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  /*echo Hello world;
*/ ?>

A. Hello world

B. Nothing

C. Error

D.

/* Hello world */

What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  define(NEW_GOOD_NAME_CONSTANT, I have a value);
define(OLD_BAD_NAME_CONSTANT, NEW_GOOD_NAME_CONSTANT);
�echo NEW_GOOD_NAME_CONSTANT;
echo OLD_BAD_NAME_CONSTANT;
?>

A. I have a value

B. I have a valueI have a value

C. ERROR

D. I have a valueNEW_GOO_NAME_CONSTANTS

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

What will be the output of the following PHP code? If say date is 22/06/2013.
     <?php      printf( date(t) )     ?> 

A. 30

B. 22

C. JUNE

D. 2013

What is the correct answer?

4

If session.use_cookie is set to 0, this results in use of..

A. Session

B. Cookie

C. URL rewriting

D. Nothing happens

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

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  $color1 = red;
$color2 = green;
echo $color1.$color2;
?>

A. red green

B. red

C. green

D. error

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

PHP files have a default file extension of..


A.

.html


B.

.xml


C.

.php


D.

.ph


E.

.asp


F.

.jsp


What is the correct answer?

4

What will be the output of the following PHP code ?
 <?php  define('GOOD_OCTAL', 0700);
define('BAD_OCTAL', 0600);
print GOOD_OCTAL;
print '
';
print BAD_OCTAL;
?>

A. 448
384

B. 0700
0800

C. ERROR

D. No output

What is the correct answer?

4

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

A.

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

B.

Array ( [peter] => 35 [ben] => 37 [joe] => 43 )

C.

Array ( [PETER] => 35 [BEN] => 37 [JOE] => 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  $i = 0;
while ((--$i > ++$i) - 1){ print $i;
} ?>

A. 00000000000000000000….infinitely

B. -1-1-1-1-1-1-1-1-1-1…infinitely

C. no output

D. error

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. red

B. green

C. red green

D. redgreen

What is the correct answer?

4

What will be the output of the following PHP code?
 <?php  $a1 = array(red, green);
$a2 = array(blue, yellow);
print_r(array_merge($a1, $a2));
?>

A.

Array ( [0] => red [1] => green)

B.

Array ( [0] => blue [1] => yellow [2] => red [3] => green )

C.

Array ( [0] => red [1] => green [2] => blue [3] => yellow )

D.

Array ( [0] => blue [1] => yellow )

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

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

A. 11

B. 2

C. 0

D. 1

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   $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  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

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 )