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)
D.
ii) and iv)
A variable can’t start with a number. Also $this is a special variable that can’t be assigned, but $This can be assigned
<?php $color1 = red;
$color2 = 1;
echo $color1 + $color2;
?>
red1
red 1
0
1
<?php $color = red;
$color = green;
echo $color;
?>
red
green
red green
error
lastmod()
getlastmod()
last_mod()
get_last_mod()
<?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
Integer
String
Boolean
Float
<?php $color = red;
echo $color . red ;
?>
red red
red
error
nothing
Complete text representation of month
Day of month, with leading zero
Daylight saving time
Day of month, without zeros
PHP files have a default file extension of..
.html
.xml
.php
.ph
.asp
.jsp
<?php /*echo Hello world;
*/ ?>
Hello world
Nothing
Error
/* Hello world */
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 define(__LINE__, PHP is a scripting language);
echo __LINE__;
?>
PHP is a scripting language
__LINE__
2
ERROR
<?php $i = 0;
while(++$i || --$i){ print $i;
} ?>
1234567891011121314….infinitely
01234567891011121314…infinitely
1
0
<?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 ) )
<?php define(GREETING, PHP is a scripting language);
echo $GREETING;
?>
$GREETING
no output
PHP is a scripting language
GREETING
<?php $i = 2;
while (++$i){ while ($i --> 0) print $i;
} ?>
210
10
no output
infinite loop
<?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 printf( date(t) ) ?>
30
22
JUNE
2013
<?php class myObject { }define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT;
?>
test
error
myObject::CONSTANT
no output
<?php $i = 5;
while (--$i > 0){ $i++;
print $i;
print hello;
} ?>
4hello4hello4hello4hello4hello…..infinite
5hello5hello5hello5hello5hello…..infinite
no output
error
<?php $i = 5;
while (--$i > 0 && ++$i){ print $i;
} ?>
5
555555555…infinitely
54321
error
<?php $i = ;
while ($i = 10){ print hi;
}print hello;
?>
hello
infinite loop
hihello
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
<?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 )
<?php define(VAR_NAME,test);
${VAR_NAME} = value;
echo VAR_NAME;
echo ${VAR_NAME};
?>
test
testtest
testvalue
error, constant value cannot be changed
T
N
E
I
<?php $color1 = red;
$color2 = green;
echo $color1 . $color2;
?>
red
green
red green
redgreen
<?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 $color1 = red;
$color2 = 1;
$color3 = greyecho $color1 + $color2 . $color3;
?>
1grey
grey
0
red1grey
<?php $i = 0;
while ($i = 10){ print hi;
}print hello;
?>
hello
infinite loop
hihello
error
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)