HH\Lib\Str\length
Returns the length of the given string represented in number of bytes
namespace HH\Lib\Str;
function length(
string $string,
): int;
This function is O(1)
: it always returns the number of bytes in the string,
even if a byte is null. For example, Str\length("foo\0bar")
is 7, not 3.
See Str\length_l()
for the length in characters.
Guide
Parameters
string $string
Returns
int
Examples
$result = Str\length("example_string");
echo($result);
//result: 14
$result = Str\length("");
echo($result);
//result: 0