<?php class myObject { }define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT;
?>
test
error
myObject::CONSTANT
no output
B. error
3600 sec
3600 min
3600 hrs
the browser is restarted
Complete text representation of month
Day of month, with leading zero
Daylight saving time
Day of month, without zeros
<?php define('GOOD_OCTAL', 0700);
define('BAD_OCTAL', 0600);
print GOOD_OCTAL;
print '
';
print BAD_OCTAL;
?>
384
0800
ERROR
No output
Integer
String
Boolean
Float
<?php $i = 0;
while(++$i || --$i){ print $i;
} ?>
1234567891011121314….infinitely
01234567891011121314…infinitely
1
0
<?php define('GREETING_TEST', 'PHP is a scripting language', true);
echo GREETING_TESt;
$changing_variable = 'test';
echo constant('GREETING_' . strtoupper($changing_variable));
?>
PHP is a scripting language
GREETING_TESt
PHP is a scripting language
GREETING_TEST
totime(+45)
totime(+45 days)
strtotime(+45 days)
strtotime(-45 days)
<?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 /*echo Hello world;
*/ ?>
Hello world
Nothing
Error
/* Hello world */
$date = Date(22 JUNE 2013)
$date = new Date(JUNE 22 2013)
$date = DateTime(22 JUNE 2013)
$date = new DateTime(22 JUNE 2013)
<?php define(__LINE__, PHP is a scripting language);
echo __LINE__;
?>
PHP is a scripting language
__LINE__
2
ERROR
A PHP script should start with ___ and end with ___:
< php >
< ? php ?>
<?php ?>
<% %>
<?php $a1 = array(red, green);
$a2 = array(blue, yellow);
print_r(array_merge($a1, $a2));
?>
Array ( [0] => red [1] => green)
Array ( [0] => blue [1] => yellow [2] => red [3] => green )
Array ( [0] => red [1] => green [2] => blue [3] => yellow )
Array ( [0] => blue [1] => yellow )
<?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);
?>
Array ( [d] => yellow )
Array ( [c] => blue )
Array ( [a] => red )
Array ( [e] => yellow )
<?php $color1 = red;
$color2 = green;
echo $color1.$color2;
?>
red green
red
green
error
<?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)
<?php class myObject { }define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT;
?>
test
error
myObject::CONSTANT
no output
<?php define(GREETING, PHP is a scripting language);
echo $GREETING;
?>
$GREETING
no output
PHP is a scripting language
GREETING
<?php $i = 5;
while (--$i > 0 || ++$i){ print $i;
} ?>
54321111111….infinitely
555555555…infinitely
54321
5
<?php printf( date(t) ) ?>
30
22
JUNE
2013
time()
mktime()
mrtime()
mtime()
<?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 files have a default file extension of..
.html
.xml
.php
.ph
.asp
.jsp
<?php $i = 0;
while (++$i && --$i){ print $i;
} ?>
1234567891011121314….infinitely
01234567891011121314…infinitely
no output
error
Session
Cookie
URL rewriting
Nothing happens
<?php $color1 = red;
$color2 = red;
echo $color1 + $color2;
?>
redgreen
red green
0
1
<?php $i = 2;
while (++$i){ while (--$i > 0) print $i;
} ?>
210
10
no output
infinite loop
<?php $i = 0;
while ($i = 10){ print hi;
}print hello;
?>
hello
infinite loop
hihello
error
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
All of the mentioned.
Only ii)
ii) and iii)
ii), iii) and iv)