strlen
Returns the length of a string in bytes.
Parameters
Return Values
Returns the length of the string in bytes
Notes
- Returns the number of bytes rather than the number of characters in a string
- For multibyte characters, use mb_strlen() instead for accurate character counting
- Whitespace characters are counted as part of the string length
- Null bytes (\0) are counted and do not terminate the string like in C
Changelog
- 8.0.0: Passing null to strlen() is deprecated and will throw a TypeError
Related Functions
is_array
VariableChecks whether a variable is an array.
count
ArrayCounts all elements in an array or properties in an object that implements Countable.
isset
VariableDetermines if a variable is declared and is different than null.
empty
VariableDetermines whether a variable is empty. A variable is considered empty if it does not exist or if its value equals false.
preg_match
RegExPerforms a regular expression match against a string and returns whether a match was found.
password_hash
SecurityCreates a password hash using a strong one-way hashing algorithm for secure password storage.
htmlspecialchars
SecurityConverts special characters to HTML entities to prevent XSS attacks and ensure safe HTML output.
filter_var
ValidationFilters a variable with a specified filter, used for validating and sanitizing data.