3 ms·
Well, It is not that easy. For example, take the function strlen(). You can see that it is a wrapper for the C function. So can you expect that it will behave
by babyrainbow 10y ago
Well, It is not that easy. For example, take the function strlen(). You can see that it is a wrapper for the C function.
So can you expect that it will behave like the c function, accepting strings only? No! It now accept both strings and integers. So you have part perl there.
Now take another function. ctype_digit(). I don't know where the name come from. You expect it to behave like strlen() accepting both strings and numbers. But no!
If you pass it a number, it won't even bat an eye (throw an exception or error), but it will just return gibberish...
Hope my point, that these influences are mixed together in a haphazard fashion, is a bit more clear now...
- marklgr 10y agoIt's more about automatic type conversion than the API, though; numerics magically get converted to strings and vice-versa. This is convenient in some cases, especially for beginners who don't have to think about types, but it eventually bites you if you never realize what happens in your back.
- Zarel 10y agoThe problem is that ctype_digit does not magically get converted to a string, it instead just returns gibberish. If ctype_digit(100) magically got converted to ctype_digit('100'), that would not be a problem.