PHP – Functions of a String
|Function||Prefix||String is first parameter?||Descriptive Name|
There’s a great amount of inconsistency here, especially with how the functions are named. For newcomers to PHP or the souls damned to hell who have to maintain WordPress plugin source code, this can be quite a barrier to writing effective code.
This isn’t even mentioning the function aliases, of which there are many: often nonsensical. For example,
join is an alias of
implode, which is one of the more sensible ones; programmers migrating from other languages may be more familiar with
split as opposed to
explode as PHP eccentrically uses.
One might expect
strlen to provide the number of characters in a string, as it does in C++, but it instead returns the number of bytes in a given string, causing problems for unicode multi-byte characters.
Additionally, it can be difficult to find the correct functions for the task at hand, and this applies to many areas of PHP stock functions. The prefixes for these are incredibly inconsistent, some beginning with
str, some beginning with
str_, some instead ending with
JS – Functions of a String
|Function||Prefix||Member of String object?||Descriptive Name|