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

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -