fork download
  1. <?php
  2.  
  3. // your code goes here
  4.  
  5. $price = 120000;
  6. $price = round(($price / 100), 2);
  7.  
  8. echo $price;
  9. echo "\n";
  10. echo number_format($price, 2, '.', '');
  11.  
  12. echo "\n";
  13.  
  14.  
  15. // 使用辅助函数
  16. $price = 120000;
  17. function fenToYuan($price)
  18. {
  19. $price = round(($price / 100), 2);
  20. return number_format($price, 2, '.', '');
  21. }
  22.  
  23. echo fenToYuan($price);
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
1200
1200.00
1200.00