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)
B.
i), ii) and iii)
echo(), print() and printf() all three can be used to output a statement onto the screen. The sprintf() statement is functionally identical to printf() except that the output is assigned to a string rather than rendered to the browser.
<?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)
<?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 $color1 = red;
$color2 = green;
echo $color1.$color2;
?>
red green
red
green
error
<?php $color1 = red;
$color2 = green;
echo $color1 + $color2;
?>
redgreen
red green
0
error
<?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 class myObject { }define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT;
?>
test
error
myObject::CONSTANT
no output
<?php printf( date(t) ) ?>
30
22
JUNE
2013
1800
3600
1440
1540
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 $i = 2;
while (++$i){ while ($i --> 0) print $i;
} ?>
210
10
no output
infinite loop
<?php $color = red;
$color = green;
echo $color;
?>
red
green
red green
error
<?php $i = 5;
while (--$i > 0 && ++$i){ print $i;
} ?>
5
555555555…infinitely
54321
error
<?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 )
lastmod()
getlastmod()
last_mod()
get_last_mod()
<?php define(VAR_NAME,test);
${VAR_NAME} = value;
echo VAR_NAME;
echo ${VAR_NAME};
?>
test
testtest
testvalue
error, constant value cannot be changed
<?php define(__LINE__, PHP is a scripting language);
echo __LINE__;
?>
PHP is a scripting language
__LINE__
2
ERROR
time()
mktime()
mrtime()
mtime()
PHPSESSID
PHPSESID
PHPSESSIONID
PHPIDSESS
start_session()
session_start()
session_begin()
begin_session()
Integer
String
Boolean
Float
<?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 )
3
4
5
6
<?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 $i = 5;
while (--$i > 0 || ++$i){ print $i;
} ?>
54321111111….infinitely
555555555…infinitely
54321
5
<?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
redgreen
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 define('IF', 42);
echo IF: , IF;
?>
IF:42
No output
IF:
ERROR
360
180
3600
1800
Which of following variables can be assigned a value to it?
i) $3hello
ii) $_hello
iii) $this
iv) $This
All of the mentioned
Only ii)
ii), iii) and iv)
ii) and iv)