Jump to content

Invalid numeric literal


Destramic
Go to solution Solved by kicken,

Recommended Posts

hey guys im tyring to pass a integer to a method and i get this error:

 

 

Invalid numeric literal

 

 

when using this code

$this->get_model('contract:contracts')->send_verification_pin(070000000000);

i could use quotes like so 

$this->get_model('contract:contracts')->send_verification_pin('070000000000');

but then the integer has the 0 missing at the beginning...this is my debug

int(7000000000)
/^07\d{9}$/
["Phone Number: Invalid phone number."]

where is this missing 0 please guys? :suicide:

 

thank you

Edited by Destramic
Link to comment
Share on other sites

  • Solution

Numbers that begin with a 0 are octal based numbers. I'd guess you get the error due to running a 32-bit version of PHP, in which case 070000000000 is larger than PHP can handle as an integer.

 

On a related note, don't try and treat phone numbers as actual numbers, treat them a strings. Just because some value only consists of digits doesn't mean it needs to be treated as an integer type.

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.