Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm sitting on a machine with en_US locale and this piece of PHP code

setlocale(LC_ALL,'de_DE.utf8');
var_dump((string)1.234);

returns

string(5) "1.234"

whereas on my colleague's machine which has a German locale, it returns

string(5) "1,234"

Why the heck does PHP use the locale when typecasting floats to strings? How can I disable it? I'd like to have this function return string(5) "1.234" on all machines, regardless of any locale settings.

Secondly and less important: Why does PHP ignore the setlocale on my machine?

share|improve this question
it doesn't ignore the setlocale, you have to have the locale installed, (doesn't work in windows) check the return value of setlocale if its FALSE then you don't have the locale. – DevZer0 32 mins ago
@DevZer0.. a right, I guess it just isn't installed on my machine... – Treecj 27 mins ago

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.