1

Possible Duplicate:
Is there any particular difference between intval and (int)?

These two statements are, afaik, identical:

$i = (int)getSomeValue();

and

$i = intval(getSomeValue());

Is there are good reason to choose one over the other (e.g. performance, treatment of nulls or objects, etc.)?

Community
  • 1
  • 1
Peter Howe
  • 1,403
  • 2
  • 16
  • 30

1 Answers1

0

In contrast to casting, intval also allows non-decimal bases.

Additionally, every programmer knows functions and can easily look them up at php.net/function, whereas casts are not as widely known.

phihag
  • 278,196
  • 72
  • 453
  • 469