|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-02-18 18:37 UTC] php at displague dot com
[2008-11-07 11:56 UTC] vrana@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sat Mar 14 01:00:01 2026 UTC |
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