Answer & Solution
strlen()
function in PHP is used to return the length of a string. Therefore, strlen('Hello')
will return 5
, as the string 'Hello'
contains five characters.
| PHP | MYTAT"> | PHP | MYTAT">
strlen('Hello')
strlen()
function in PHP is used to return the length of a string. Therefore, strlen('Hello')
will return 5
, as the string 'Hello'
contains five characters.
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 PHP functions is used to convert a string to uppercase?
A). strtoupper()
B). ucwords()
C). strtolower()
D). ucfirst()
Which of the following PHP functions is used to find the length of an array?
A). count()
B). length()
C). size()
D). sizeof()
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
$name = 'John';
echo 'Hello, $name!';
?>
A). Hello, John!
B). Hello, $name!
C). Hello, !
D). Undefined variable: name
Which of the following is a valid variable name in PHP?
A). $my_var
B). $my-var
C). $my var
D). my_var
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 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 PHP operators is used to compare whether two values are equal and of the same data type?
A). ===
B). ==
C). =
D). !=
What data type is the variable $age = 25;
in PHP?
A). Integer
B). String
C). Boolean
D). Float