PHP – Why some string function name without underscore e.g strlen?

Solution:

Many of these functions are named after the C functions which they are patterned after. This isn’t specific to string functions; a lot of other basic PHP functions are copied from C programming interfaces: printf()fopen()fnmatch()

strlen() is a perfect example. The C function is functionally identical to the PHP function.

strpos() doesn’t literally appear in the C standard library, but strstr() and strchr() do; the naming pattern is pretty clear. (The distinction between strstr() and strpos() isn’t relevant in C, as returning a pointer to a substring doesn’t have any overhead.)

There isn’t a strtoupper() or strtolower() in C either, but there is a family of functions which convert strings to various types of numbers (strtol()strtof()strtoull(), etc), which may have inspired these names.

As an aside, the old MySQL extension was similarly a direct replica of the MySQL C API, even down to grody details like the name of mysql_real_escape_string().