Answer & Solution
30
, as $x
will be converted to the integer 10
, and then added to $y
, resulting in 30
.
$y = 20;
echo $x + $y;
?> | PHP | MYTAT">
$y = 20;
echo $x + $y;
?> | PHP | MYTAT">
<?php
$x = '10';
$y = 20;
echo $x + $y;
?>
30
, as $x
will be converted to the integer 10
, and then added to $y
, resulting in 30
.
What is the correct way to declare a variable in PHP?
A). $name = 'John';
B). name = 'John';
C). var name = 'John';
D). String name = 'John';
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];
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;
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 data type is the variable $age = 25;
in PHP?
A). Integer
B). String
C). Boolean
D). Float
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 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;
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
What is the purpose of the following PHP function?strlen('Hello')
A). Returns the length of a string
B). Converts a string to lowercase
C). Checks if a string contains a substring
D). Returns the first occurrence of a substring in a string
Which of the following statements is true about PHP comments?
A). Comments are ignored by the PHP interpreter
B). Comments can only be single-line
C). Comments must start with /* and end with */
D). Comments are displayed on the webpage