| 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

What is the purpose of the following PHP code?

<?php
$colors = array('Red', 'Green', 'Blue');
foreach ($colors as $color) {
echo $color . '
';
}
?>

A). To loop through an array and print each element

B). To check if a variable is an array

C). To reverse the elements of an array

D). To create a new array

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 functions is used to find the length of an array?

A). count()

B). length()

C). size()

D). sizeof()

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

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
$x = 5;
echo $x--;
echo $x;
?>

A). 5 4

B). 5 5

C). 4 4

D). 4 5

Which of the following PHP operators is used for concatenation of strings?

A). .

B). +

C). &&

D). *

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