Answer & Solution
.
) operator is used for concatenation of strings. It joins two string values together to form a single string. For example, 'Hello' . ' ' . 'World'
will result in 'Hello World'
.
.
) operator is used for concatenation of strings. It joins two string values together to form a single string. For example, 'Hello' . ' ' . 'World'
will result in 'Hello World'
.
What will be the value of the variable $result
after executing the following PHP code?<?php
$x = 5;
$result = ($x > 10) ? 'Yes' : 'No';
?>
A). Yes
B). No
C). True
D). False
Which of the following PHP functions is used to convert a string to uppercase?
A). strtoupper()
B). ucwords()
C). strtolower()
D). ucfirst()
What will be the output of the following PHP code?<?php
$x = 10;
echo ++$x;
?>
A). 10
B). 11
C). 9
D). Error
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 will be the output of the following PHP code?<?php
$x = 5;
$y = 10;
echo 'The sum is: ' . ($x + $y);
?>
A). The sum is: 15
B). The sum is: 5 + 10
C). The sum is: $x + $y
D). The sum is: 510
What will be the output of the following PHP code?<?php
$x = 5;
echo $x--;
echo $x;
?>
A). 5 4
B). 5 5
C). 4 4
D). 4 5
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
What will be the result of the expression 'Hello' . ' World'
in PHP?
A). 'Hello World'
B). 'Hello . World'
C). 'Hello + World'
D). 'Hello, World'
Which of the following is a valid variable name in PHP?
A). $my_var
B). $my-var
C). $my var
D). my_var
What does the following PHP code output?<?php
$x = '10';
$y = 20;
echo $x + $y;
?>
A). 30
B). 1020
C). Error
D). 102