Integer
String
Boolean
Float
B. String
<?php define(__LINE__, PHP is a scripting language);
echo __LINE__;
?>
PHP is a scripting language
__LINE__
2
ERROR
<?php $color1 = red;
$color2 = red;
echo $color1 + $color2;
?>
redgreen
red green
0
1
<?php define('IF', 42);
echo IF: , IF;
?>
IF:42
No output
IF:
ERROR
<?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;
?>
I have a value
I have a valueI have a value
ERROR
I have a valueNEW_GOO_NAME_CONSTANTS
<?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();
?>
0.01.0
01
No output
ERROR
<?php $i = 0;
while (++$i && --$i){ print $i;
} ?>
1234567891011121314….infinitely
01234567891011121314…infinitely
no output
error
<?php $color1 = red;
$color2 = green;
echo $color1.$color2;
?>
red green
red
green
error
<?php $color1 = 1;
$color2 = 1;
echo $color1 + $color2;
?>
11
2
0
1
<?php $i = 2;
while (++$i){ while ($i --> 0) print $i;
} ?>
210
10
no output
infinite loop
What does PHP stand for?
i) Personal Home Page
ii) Hypertext Preprocessor
iii) Pretext Hypertext Processor
iv) Preprocessor Home Page
Both i) and iii)
Both ii) and iv)
Only ii)
Both i) and ii)
Which of the following PHP statements will output Hello World on the screen?
i) echo (“Hello World”);
ii) print (“Hello World”);
iii) printf (“Hello World”);
iv) sprintf (“Hello World”);
i) and ii)
i), ii) and iii)
All of the mentioned
i), ii) and iv)
<?php $color = red;
echo $color . red ;
?>
red red
red
error
nothing
<?php class myObject { }define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT;
?>
test
error
myObject::CONSTANT
no output
<?php echo Today is .date(F d, Y) ?>
Today is 22 June, 2013
Today is 22-06-2013
Today is 06-22-2013
Today is June 22, 2013
<?php /*echo Hello world;
*/ ?>
Hello world
Nothing
Error
/* Hello world */
T
N
E
I
What will be the output of the following code?
<?php
$foo = 'Bob';
$bar = &$foo;
$bar = "My name is $bar";
echo $bar;
echo $foo;
?>
Error
My name is BobBob
My name is BobMy name is Bob
My name is Bob Bob
<?php $i = 5;
while (--$i > 0 && ++$i){ print $i;
} ?>
5
555555555…infinitely
54321
error
<?php $i = 0;
while ((--$i > ++$i) - 1){ print $i;
} ?>
00000000000000000000….infinitely
-1-1-1-1-1-1-1-1-1-1…infinitely
no output
error
PHPSESSID
PHPSESID
PHPSESSIONID
PHPIDSESS
<?php $a = array(red, green, blue);
array_pop($a);
print_r($a);
?>
Array ( [0] => red [1] => green )
Array ( [0] => green [1] => blue )
Array ( [0] => red [1] => blue )
Array ( [0] => blue [1] => blue )
Integer
String
Boolean
Float
<?php define(VAR_NAME,test);
${VAR_NAME} = value;
echo VAR_NAME;
echo ${VAR_NAME};
?>
test
testtest
testvalue
error, constant value cannot be changed
<?php $cars = array(Volvo, BMW, Toyota);
echo I like . $cars[0] . , . $cars[1] . and . $cars[2] . .;
?>
I like Volvo BMW and Toyota.
I like Volvo, BMW and Toyota)
I like Volvo, BMW and Toyota.
I like. Volvo.,. BMW. and. Toyota)
1800
3600
1440
1540
Complete text representation of month
Day of month, with leading zero
Daylight saving time
Day of month, without zeros
<?php $color1 = red;
$color2 = green;
echo $color1 + $color2;
?>
redgreen
red green
0
error
<?php $i = 5;
while (--$i > 0 || ++$i){ print $i;
} ?>
54321111111….infinitely
555555555…infinitely
54321
5
3
4
5
6
<?php $age = array(Peter=>35, Ben=>37, Joe=>43);
print_r(array_change_key_case($age, CASE_UPPER));
?>
Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )
Array ( [peter] => 35 [ben] => 37 [joe] => 43 )
Array ( [PETER] => 35 [BEN] => 37 [JOE] => 43 )
Array ( [PeTeR] => 35 [BeN] => 37 [Joe] => 43 )