Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
string
communitycreator

What is strlen() in PHP?

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The strlen() function in PHP is used to calculate the size of a string.

The illustration below shows the mathematical representation of the strlen() function.

Visual representation of strlen() function

Syntax

strlen(string)

Parameters

The strlen() function requires a string as a parameter.

Return value

This function returns the size of a string.

Code

<?php
echo("The size of string 'hello': ");
echo(strlen("hello"));
echo("\n");
echo("The size of string 'educative': ");
echo(strlen("educative"));
?>

RELATED TAGS

php
string
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring