note 56678 added to language.types.string

From: Date: Mon, 12 Sep 2005 10:17:37 +0000
Subject: note 56678 added to language.types.string
Groups: php.notes 
Request: Send a blank email to php-notes+get-95043@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/language.types.string.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56678 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56678&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56678&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56678&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56678&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56678&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56678&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56678&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#95043) next »