HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

mb_strlen

Description

The mb_strlen of Multibyte String for PHP get string length.

Syntax

mb_strlen(
    string $string,
    ?string $encoding = null
): int

Parameters

string

The string being checked for length.

encoding

The encoding parameter is the character encoding. If it is omitted or null, the internal character encoding value will be used.

Return

Returns the number of characters in string string having character encoding encoding. A multi-byte character is counted as 1.

Examples

1 · string

<?

$string = 'string🐘string🐘string';

$return = mb_strlen($string);

echo $return;
20

2 · encoding

<?

$string = 'string🐘string🐘string';
$encoding = 'UTF-8';

$return = mb_strlen($string, $encoding);

echo $return;
20