Answer & Solution
strtoupper() function in PHP is used to convert a string to uppercase. It returns a string with all alphabetic characters converted to uppercase. Therefore, strtoupper('hello') will return 'HELLO'.
strtoupper() function in PHP is used to convert a string to uppercase. It returns a string with all alphabetic characters converted to uppercase. Therefore, strtoupper('hello') will return 'HELLO'.
Which of the following is a correct way to assign a floating-point number to a variable in PHP?
A). $price = 10.99;
B). $price = '10.99';
C). $price = '10.99';
D). $price = 10;
Which of the following PHP operators is used for concatenation of strings?
A). .
B). +
C). &&
D). *
What will be the output of the following PHP code?<?php
$name = 'John';
echo 'Hello, $name!';
?>
A). Hello, John!
B). Hello, $name!
C). Hello, !
D). Undefined variable: name
What will be the result of the expression 'Hello' . ' World' in PHP?
A). 'Hello World'
B). 'Hello . World'
C). 'Hello + World'
D). 'Hello, World'
What will be the output of the following PHP code?<?php
$x = 10;
$y = 5;
echo $x + $y;
?>
A). 15
B). 5
C). 10
D). Error
Which of the following is a correct way to increment the value of a variable $count by 1 in PHP?
A). $count++;
B). $count += 1;
C). $count = $count + 1;
D). $count =+ 1;
Which of the following PHP operators is used to compare whether two values are equal and of the same data type?
A). ===
B). ==
C). =
D). !=
What will be the result of the expression 10 % 3 in PHP?
A). 0
B). 1
C). 3
D). 10
What is the value of $x after the following PHP code is executed?<?php
$x = 5;
$x += 3;
echo $x;
?>
A). 5
B). 8
C). 15
D). 3
Which of the following is a correct way to declare an array in PHP?
A). $colors = array('Red', 'Green', 'Blue');
B). $colors = 'Red, Green, Blue';
C). $colors = {'Red', 'Green', 'Blue'};
D). $colors = [Red, Green, Blue];