NumberFormat

number_format

 

<?php
print(number_format(1000) . "\n");              // 1,000
print(number_format('1000') . "\n");            // 1,000
print(number_format((float)'A') . "\n");        // 0
print(number_format((float)'あ') . "\n");       // 0
print(number_format((float)'') . "\n");         // 0
print(number_format((float)null) . "\n");         // 0

<?php
print(number_format(null) . "\n"); // 0

<?php
print(number_format('') . "\n");

PHP Fatal error: Uncaught TypeError: number_format(): Argument #1 ($num) must be of type float, string given in test1.php:2

投稿日: