From: php at displague dot com Operating system: linux PHP version: 5.2.5 PHP Bug Type: Unknown/Other Function Bug description: money_format treats 0, "", and null differently
Description: ------------ There is an unexpected (or undocumented) aspect of money_format. When supplied with 0 or null as a value it returns the formatted version of those values. When an empty string is supplied as the value, null is returned. Null and '' should be treated the same way in this case. This behavior may be understandable when a non-numeric string is submitted, but a notice should probably be emitted. Reproduce code: --------------- <?php ini_set('display_errors',true); error_reporting(E_ALL & E_STRICT); foreach(array("0"=>0,"''"=>"",'null'=>null,"'dummy'"=>'dummy',"'2'"=>'2') as $desc=>$value) { $mf = money_format("%(n",$value); echo "value: $desc\tformat:'".$mf."'\tis_null: ".(string)(int)is_null($mf)."\n"; } Expected result: ---------------- value: 0 format:'0.00' is_null: 0 value: '' format:'' is_null: 1 value: null format:'0.00' is_null: 0 value: 'dummy' format:'' is_null: 1 value: '2' format:'2.00' is_null: 0 Actual result: -------------- value: 0 format:'0.00' is_null: 0 value: '' format:'0.00' is_null: 0 value: null format:'0.00' is_null: 0 value: 'dummy' format:'0.00' is_null: 0 value: '2' format:'2.00' is_null: 0 -- Edit bug report at http://bugs.php.net/?id=44156&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44156&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44156&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44156&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44156&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44156&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44156&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44156&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44156&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44156&r=support Expected behavior: http://bugs.php.net/fix.php?id=44156&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44156&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44156&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44156&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44156&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44156&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44156&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44156&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44156&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44156&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44156&r=mysqlcfg