I'm building a kind of accounting system with PHP and MySQL. My database has DECIMAL (11,2)
columns for currency, and also DECIMAL
for all other values used on operations with currency (like percentages to be applied). I've never programmed something like that before, so I am not sure I am doing the right thing.
Am I using the correct level of precision at the database?
On the PHP side:
Should I use BC Math functions on any values that may be later stored on the database?
I also have to format the money values with ,
as the decimal point, and .
as the thousands separator. I know number_format
, and recently discovered money_format
, but the manual says both operate with floats.
Can I use number_format
or money_format
for values that will be displayed, or exported to CSV or Excel?