0

i'm curious how something like this would work

class Test
{
    public $price;
}

$obj = new Test();
$obj->price = 4500.00;

echo $obj->price;

how can I return that value as 4500.00 and not 4500?

4

1 回答 1

2
echo number_format($obj->price,2);

If you don't what the thousands seperator:

echo number_format($obj->price,2,'.','');

See number_format

于 2012-06-14T04:40:49.863 回答