|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-01-08 22:04 UTC] pmoulding at tedis dot com dot au
When I write a function as xxx(1.0, 1.8); The function receives 1 and 1.8, not 1.0 and 1.8. I tried get_func_arg() and other tricks but the 1.0 is converted to int(1) before it available for processing. Could we have a language construct named: get_func_arg_untouched_virginal_string_as_entered() which keeps the parameter as a string? I need to keep some numeric data in the original input format so it can be verified as typed and passed to other systems in the original format. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 14:00:01 2025 UTC |
You must be doing something else wrongly: <?php function foo($a, $b) { var_dump ($a, $b); } foo(1.0, 1.8); ?> [derick@kossu derick]$ php bug21537.php float(1) float(1.8) As you see it works fine... DerickHi Peter, One minor note here. The first argument is not converted to type integer. Rather, it is trimmed of non-numerically significant zeros. function xxx($a,$b){ var_dump($a,$b); } xxx(2.0, "2.0"); Outputs: float(2) string(3) "2.0" The type of the value is still float. This behaviour might be difficult to change, considering that it happens in all contexts - not just when formal parameters are passed to a function. $a = 2.0; var_dump($a); var_dump(2.0); Outputs: float(2); float(2); Cheers!