Same for intval
/ (int)
, floatval
/ (float)
, etc.
As far as I can make out, neither changes the original variable, and they both return the casted version. They appear to be functionally identical.
Are there edge cases where there's a difference?
Any reason to ever use one over the other?
Best practice?
I'm assuming that (bool)
is "better", as I figure it's probably quicker than a function call that internally probably just does the same thing. If that's the case though, what's the point of these boolval
/intval
/floatval
functions?
For the most part they are identical, however there are subtle differences:
intval
accept a second parameter ($base
), which the cast syntax does notarray_map('intval', ..)
), which is not possible with the cast syntax If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With