note 56678 deleted from language.types.string by colder
| From: | colder@php.net | Date: | Tue, 17 Oct 2006 18:22:24 +0000 |
| Subject: | note 56678 deleted from language.types.string by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-118647@lists.php.net to get a copy of this message | ||
Note Submitter: php at simoneast dot NOSPAM dot net
----
Be ULTRA careful when multiplying numbers like '1,000'. If it's a string with a
thousands separator like that, PHP ignores everything after the comma.
<?
echo "2,500" * 2; // displays 4
echo "20,50" * 2; // displays 4
echo "2,500.00" * 2; // displays 4
is_numeric("2,500"); // false
?>
I was developing a shopping cart, and had items worth over $1,000 advertised as $1! Luckily we
realised before launch.