Php reads the double type of mysql with incorrect decimal point

data table design
clipboard.png


clipboard.png

php:

clipboard.png

Php
Apr.18,2022
The double type of

mysql is a floating point number, which is the saved floating point difference. For more information, please see here . The same is true for other languages. The price is recommended to use decimal type.


this problem occurs when you use json_encode since php7.1 . You can first convert a floating point number to a string


just keep two decimal places rounded.

Menu