Get PHP String Length

Get PHP String Length

To Get PHP String Length we can use strlen in PHP, what it can do is it will counts number of characters for give string, word or paragraph. And output will be always an integer because that will be a number. It takes only one argument, that is string or a variable. String Length function in PHP, it will counts white spaces also. For example if you have a string to count number of characters then it will count white spaces, special characters and everything.

Syntax for PHP String Length

[php] $output = strlen($string)

$output will be an integer because this is string length, and $string will be a string, word or paragraph.

Note: $string argument is mandatory.

If the string is empty $output will be zero(0), or it will return an integer value after execution if it’s correct string.

PHP String Length – Sample code Snippets

Simple PHP String Length code snippet with String, and output is 12.
[php] echo strlen("Hello world!");

Passing this string as a variable to strlen PHP function.
[php] $string = "Hello world!";
echo strlen($string);

If you want to learn more about strlen function, you can get information at

https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1827 NRe1o1dSaq01_LuCGghTYvfvpJWatYSrSJXn7-UrExgIBh7ORAyJuMeNQ-ChVuQh f2320fc9c733d10f5bb62c36ec7f548e46efc523&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1833 FqqbVfq3Dun9xFaITgZl47uo9GVQo3MJrDv7SOMxDMKLom_ylu3zCIRVNOlIdIB0 5f52a0bd57de33e9af38ab08e1b4e6f82106ab8d&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
Vivek Vengala

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: