Php processes money and monetary values

Are there any standards or rules that should be followed when processing money and denominations in php like .45c, .35c or $ 4.00 as values?

I do not want to do this 400 cents as a value for $ 4.00, I just wanted to use $ 4.00 dollars, as in php without changes, as well as .50c as it is.

+3
source share
1 answer

Usually fractions are expressed as 0.45 or 0.12.

Using number_format () in PHP can help you format the values ​​in any way. There is also money_format (), which takes into account the locale settings to try to figure out how to display the currency.

, , . , - /​​ .

, . , , . , money_format(), , .

, , , Magento, Prestashop, Zencart, osCommerce .. , .


/ | number_format() | money_format()

+7

Source: https://habr.com/ru/post/1724069/


All Articles