Tuesday, March 21, 2017

",0" gets added to number after caclulations

I'm working on a laravel webapplication. Whenever I perform a calculation, ",0" gets added to the end of the number and I cannot figure out why.

To make sure there's no models interfering, I performed the tests below in my routes/web.php. This file does not have any use's or setlocale's, just Route functions.

When I run the following code

Route::get('calctest', function(){
    dd(25);
});

the response is 25. Which is to be expected. However, when I start calculating, like I've done in the example below

Route::get('calctest', function(){
    dd(25/10);
});

I get 2.5,0, where I would expect 2.5. This also happens when the result isn't a decimal. Is there any known issue that could cause the ,0 at the end?



via Stormhammer

Advertisement