Home  >  Article  >  Backend Development  >  Note on PHP functions

Note on PHP functions

巴扎黑
巴扎黑Original
2016-11-29 11:01:231421browse

1.sprintf('%.1f',$str) is weird, is it rounding?

<?php  
  echo  sprintf(&#39;%.1f&#39;,7.52);  // 7.5  
  echo "\n";  
  echo  sprintf(&#39;%.1f&#39;,7.55); // 7.5  
  echo "\n";  
  echo  sprintf(&#39;%.1f&#39;,7.56); // 7.6


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn