Reputation: 368
I am trying to store a phone number and I have reached some problems due to type casting? Anyone have any suggestions as to what is happening here?
var_dump((int)"6467838439"); // displays 'int 2147483647'
Upvotes: 0
Views: 109
Reputation: 2743
An integer is 32 bits and has a finite size of approximatly 2 billion so your phone number is being truncated. You should store it as a string.
Upvotes: 1
Reputation: 5201
Phone numbers should be stored as text. They generally can't be stored as integers due to integer overflow.
Upvotes: 4