What, exactly, is the purpose of the intval()
function for a base-10 calculation? Isn't it the exact same as a typecast, just slower? In all of my Googling, I haven't found a single benefit. What am I missing?
Asked
Active
Viewed 406 times
1

Nathanael
- 6,893
- 5
- 33
- 54
-
See also http://stackoverflow.com/questions/1912599/is-there-any-particular-difference-between-intval-and-int (not quite a duplicate) – John Carter Jun 26 '12 at 03:41
2 Answers
5
intval()
lets you specify a base to convert from.
$decimal_value = intval("FF", 16)
For simple base-10 conversions, there's no reason to use intval()
.

Amber
- 507,862
- 82
- 626
- 550
-
1If you constrain your question like that, then yes, there's no reason to use `intval()`... but that's kind of like asking "what's the point `preg_replace()` if I'm just doing basic string replacement, it's like `str_replace()` but slower". – Amber Jun 26 '12 at 03:38