Twitter API, PHP precision and scientific notation

If you use PHP and the Twitter API, be on the lookout for this issue.

Twitter IDs are up to 141 quadrillion (141 million billion). These Twitter IDs exceed PHP’s default precision of 14. So your Twitter IDs could be converted to scientific notation by PHP.

A Twitter ID of 141675395434037249 will be stored as 1.41675395434037249E+17 once PHP gets it’s hands on it.

This could cause code that has been working great for a while to stop working.

Edit your php.ini and set precision to 20, or use
ini_set(‘precision’, 20);

Leave a Reply

Your email address will not be published. Required fields are marked *