5 ms·
One I always like is people using "mysql_real_escape_string". Well guess what? It comes from mysql itself: https://dev.mysql.com/doc/refman/8.0/en/mysql-real-es
by arkh 7y ago
One I always like is people using "mysql_real_escape_string". Well guess what? It comes from mysql itself: https://dev.mysql.com/doc/refman/8.0/en/mysql-real-escape-string.html https://dev.mysql.com/doc/refman/8.0/en/mysql-real-escape-st...
- johannes1234321 7y agoLots of "classic" PHP is just thin wrappers of C libraries. Many of the inconsistencies in PHP come from being consistent with those libraries.
- tambourine_man 7y agoNot really. You may be surprised to learn, as I was, that PHP function hashing mechanism was strlen() in the beginning. So the number of characters was more important than naming consistency. https://news-web.php.net/php.internals/70691 https://news-web.php.net/php.internals/70691
- johannes1234321 7y agoThat is for function with no C counterparts. htmlspecialchars() exists in no common C library. The reason strlen() is called strlen() (not string_length() or length() or whatever) however is due to C.
- lioeters 7y agoYes, I was shocked to learn this about early PHP, that function names were hashed simply by their lengths - so names were chosen to fit a specific length. Pragmatic and fast? Yes. Insane design? Completely. Edit: I can also imagine this design decision must have had context. Perhaps it was a common technique in low-level programming, as a practical way to save time/space.
- johannes1234321 7y agoGiven the amount of functions in early PHP (we are talking PHP/FI 2 max here, even userlevel code hardly had functions back then) even not hashing them at all, but doing a linear search over the function table would have been acceptable. Hashing by length most likely lead to few buckets with more than 3 functions.