PHP:Why printf("%.2f", 0.02) output 0.024?why is not 0.02? -


when code :

<?php printf("%.2f", 0.02);?> 

output: 0.02

when code :

<?php var_dump(printf("%.2f", 0.02));?> 

output: 0.02int(4)

when code :

<?=printf("%.2f", 0.02)?> 

output: 0.024

<?=var_dump(printf("%.2f", 0.02))?> 

output: 0.02int(4)

why <?=printf("%.2f", 0.02)?> isn't outputing 0.02? <?=printf("%.2f", 0.02)?> correspond <?php var_dump(printf("%.2f", 0.02));?>?

i think you've missed important here. from manual

returns length of outputted string.

so, while printf outputs browser, returns length of 0.02, 4


Comments

Popular posts from this blog

Listboxes in c# -

Excel Duty List -

Multilayer CSV to filtered excel -