| PHP | MYTAT"> | PHP | MYTAT">
Q
What is the purpose of the following PHP function?

strlen('Hello')

Answer & Solution

Answer: Option A
Solution:
The 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.
Related Questions on Average

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 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 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;

Which of the following PHP functions is used to find the length of an array?

A). count()

B). length()

C). size()

D). sizeof()

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 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 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 valid variable name in PHP?

A). $my_var

B). $my-var

C). $my var

D). my_var