<?php $i = 5;
while (--$i > 0){ $i++;
print $i;
print hello;
} ?>
4hello4hello4hello4hello4hello…..infinite
5hello5hello5hello5hello5hello…..infinite
no output
error
A. 4hello4hello4hello4hello4hello…..infinite
time()
mktime()
mrtime()
mtime()
<?php $cars = array(Volvo, BMW, Toyota, Honda, Mercedes, Opel);
print_r(array_chunk($cars, 2));
?>
Array ( [0] => Array ( [1] => Volvo [2] => BMW ) [1] => Array ( [1] => Toyota [2] => Honda ) [2] => Array ( [1] => Mercedes [2] => Opel ) )
Array ( [1] => Array ( [1] => Volvo [2] => BMW ) [2] => Array ( [1] => Toyota [2] => Honda ) [3] => Array ( [1] => Mercedes [2] => Opel ) )
Array ( [0] => Array ( [0] => Volvo [1] => Volvo ) [1] => Array ( [0] => BMW [1] => BMW ) [2] => Array ( [0] => Toyota [1] => Toyota ) )
Array ( [0] => Array ( [0] => Volvo [1] => BMW ) [1] => Array ( [0] => Toyota [1] => Honda ) [2] => Array ( [0] => Mercedes [1] => Opel ) )
360
180
3600
1800
Which of the following is/are a PHP code editor?
i) Notepad
ii) Notepad++
iii) Adobe Dreamweaver
iv) PDT
Only iv)
All of the mentioned.
i), ii) and iii)
Only iii)
<?php /*echo Hello world;
*/ ?>
Hello world
Nothing
Error
/* Hello world */
<?php $color1 = red;
$color2 = red;
echo $color1 + $color2;
?>
redgreen
red green
0
1
<?php $a = array(A, Cat, Dog, A, Dog);
print_r(array_count_values($a));
?>
Array ( [A] => 2 [Cat] => 1 [Dog] => 2 )
Array ( [A] => 2 [Cat] => 2 [Dog] => 1 )
Array ( [A] => 1 [Cat] => 1 [Dog] => 2 )
Array ( [A] => 2 [Cat] => 1 [Dog] => 1)
session.domain
session.path
session.cookie_path
session.cookie_domain
start_session()
session_start()
session_begin()
begin_session()
<?php define('IF', 42);
echo IF: , IF;
?>
IF:42
No output
IF:
ERROR
<?php printf( date(t) ) ?>
30
22
JUNE
2013
<?php $color = red;
$color = green;
echo $color;
?>
red
green
red green
error
<?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 $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 )
A PHP script should start with ___ and end with ___:
< php >
< ? php ?>
<?php ?>
<% %>
<?php $color1 = 1;
$color2 = 1;
echo $color1 + $color2;
?>
11
2
0
1
<?php $color1 = red;
$color2 = green;
echo $color1.$color2;
?>
red green
red
green
error
<?php $a = array(a=>red, b=>green, c=>blue);
echo array_shift($a);
print_r ($a);
?>
green
red
redArray( [c] => green [c] => blue )
redArray( [b] => green [c] => blue )
<?php define('GOOD_OCTAL', 0700);
define('BAD_OCTAL', 0600);
print GOOD_OCTAL;
print '
';
print BAD_OCTAL;
?>
384
0800
ERROR
No output
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)
<?php echo (checkdate(4,31,2010) ? 'Valid' : 'Invalid');
?>
TRUE
FALSE
Valid
Invalid
1800
3600
1440
1540
3
4
5
6
<?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)
totime(+45)
totime(+45 days)
strtotime(+45 days)
strtotime(-45 days)
$date = Date(22 JUNE 2013)
$date = new Date(JUNE 22 2013)
$date = DateTime(22 JUNE 2013)
$date = new DateTime(22 JUNE 2013)
<?php $i = 5;
while (--$i > 0 || ++$i){ print $i;
} ?>
54321111111….infinitely
555555555…infinitely
54321
5
<?php $color = red;
echo $color . red ;
?>
red red
red
error
nothing
<?php define(__LINE__, PHP is a scripting language);
echo __LINE__;
?>
PHP is a scripting language
__LINE__
2
ERROR
<?php class myObject { }define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT;
?>
test
error
myObject::CONSTANT
no output