1. Which of the following PHP statement can appear in an if-statement if $variable is a string of characters, e.g., $var
Posted: Sun May 15, 2022 10:14 am
1. Which of the following PHP statement can appear in an
if-statement if $variable is a string of characters, e.g.,
$variable contains “Test” prior to the if-statement?
if($variable = "test") echo "OK";
if($variable == "test") echo "OK";
2. What will the following statements generate?
$variable1 = 10;
$variable2 = “10”;
if ($variable1 == $variable2)
echo “Same”;
else
echo “Different”;
An error message will be display
Different
Same
None of the above
3. What message will be displayed by following statement?
$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
Hello world. It's a beautiful day.
Helloworld.It'sabeautifulday.
An error message.
Array ( [0] => Hello [1] => world. [2] => It's [3]
=> a [4] => beautiful [5] => day. )
4. What will be displayed by following statement?
printf("%.2f", 2.345);
2.345
2.34
2.35
None of the above
if-statement if $variable is a string of characters, e.g.,
$variable contains “Test” prior to the if-statement?
if($variable = "test") echo "OK";
if($variable == "test") echo "OK";
2. What will the following statements generate?
$variable1 = 10;
$variable2 = “10”;
if ($variable1 == $variable2)
echo “Same”;
else
echo “Different”;
An error message will be display
Different
Same
None of the above
3. What message will be displayed by following statement?
$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
Hello world. It's a beautiful day.
Helloworld.It'sabeautifulday.
An error message.
Array ( [0] => Hello [1] => world. [2] => It's [3]
=> a [4] => beautiful [5] => day. )
4. What will be displayed by following statement?
printf("%.2f", 2.345);
2.345
2.34
2.35
None of the above