Why are PHP’s function names a mess?

I have always wondered this, its exceptionally hit and miss and there isnt any real standards. I recently found the reason on the internet

Well, there were other factors in play there. htmlspecialchars was a very early function. Back when PHP had less than 100 functions and the function hashing mechanism was strlen(). In order to get a nice hash distribution of function names across the various function name lengths names were picked specifically to make them fit into a specific length bucket. This was circa late 1994 when PHP was a tool just for my own personal use and I wasn't too worried about not being able to remember the few function names.

-Rasmus - citation

So it turns out they were very specifically named to make sure they would fit nicely into the hashing function… Obviously today this isn’t needed, but its an exceptionally old artefact of PHP’s past that never got changed.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.