On Tue, 2009-07-14 at 01:52 -0400, Andrew Ballard wrote:
> On Mon, Jul 13, 2009 at 4:18 PM, Haig Dedeyan<hdede...@videotron.ca> wrote:
> > for the phone #'s, I'm using int as the data type & storing each part of the
> > phone # in its own cell,
> >
> > When it gets displayed, I add a dash in between each part of the phone #'s
> > (country code-area code-1st set of digits-last set of digits)
> >
> > Cheers
> >
> > Haig
> I disagree. Telephone numbers are not actually numbers; they are
> sequences of numeric digits. Unlike IP addresses where is
> equivalent to, leading zeros are significant; they are
> part of the data, not just padding to be inserted automatically by the
> database or by a formatting function in the presentation layer. When
> you validate an area code in the North American numbering plan, do you
> validate that it is a number between 1 and 999 or do you validate that
> it is a string of exactly 3 decimal-digit characters long? Expand that
> to international phone numbers, and the zeros become even more
> significant since you can't easily make assumptions about the length
> of various segments in a phone number.
> Sorry, but I just don't see any advantage to storing them as integers.
> Andrew

Yeah, that makes sense. Last time I tried to store a phone number as a
number was at school, when I realised that none of the leading zeros
were preserved. On UK phone numbers, there's always a leading zero
unless you're calling directory enquiries or emergency services!

Also, IP addresses can be converted to IP numbers with the long2ip()
function of PHP, which means you can store them as long ints and do
normal number comparisons on them, great for matching an IP address to a
range of 'valid' ones.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to