strlen() – Finding length of a PHP string

PHP strings can be of any length, since there is no limits to the size of strings in PHP. The PHP strings can be specified using either single quote (ex. ‘This is my test string’) or using double quotes (ex. “my test string”).PHP has some in built string manipulation functions.

The strlen PHP string function is used to find the length of the given string.

Example :

<?php

$string = ‘Milap’;
echo strlen($string);
?>

Output :
5

Another Example :

<?php
$string = ‘ Milap ‘;
echo strlen($string);
?>

Output:
7

Another One :

<?php
$string = ‘ Mi l a p ‘;
echo strlen($string);
?>

Output :
10

In php a "space" is countable as a part of the string & it is countable
in the lenght of the string.
Advertisements

I like to hear from you about this !!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s