php - number_format() causes errors in Apache log -


i using number_format round floats 2 decimal digits. problem of inputs dont have more 2 decimals digits begin with. code:

number_format($value, 2) 

instead of peacefully adding 0 in case doesn't have enough decimal digits, raises errors inside apache log , that's not desirable.

how fix this?

edit:

so number_format(2.1, 2) or number_format(0, 2) raise error in apache log.

[thu jun 30 17:18:04 2011] [error] [client 127.0.0.1] php notice: non formed numeric value encountered in /home/tahoang/desktop/projects/weatherdata/weatherdata.php on line 41

try type casting first parameter of number_format() float:

$format = number_format((float)0, 2); 

or

$format = number_format(floatval(0), 2); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -