วันพุธที่ 30 เมษายน พ.ศ. 2557

10:30

ฟังก์ชัน bccomp()
เปรียบเทียบเลข ด้วยฟังก์ชัน bccomp()




รูปแบบ
string bccomp ( string $left_operand , string $right_operand , int $scale )
$left_operand คือ ตัวเลขด้านซ้าย รูปแบบ string
$right_operand คือ ตัวเลขด้านขวา รูปแบบ string
$scale คือ จำนวนจุดทศนิยม

ค่า return
0 ถ้าตัวเลขเท่ากัน
1 ถ้า $left_operand มากกว่า $right_operand
-1 กรณีอื่นๆ
ตัวอย่าง
<?php

echo bccomp('1', '2') ;
echo bccomp('1.00001', '1', 3);
echo bccomp('1.00001', '1', 5);

?>
ผลลัพธ์
-1
0
1

0 ความคิดเห็น:

แสดงความคิดเห็น