3 ms·
I like setlocale() as a central knob that other functions obey. Works a-OK for me on several different websites. Normally my website's code starts with platform
by dexen 15y ago
I like setlocale() as a central knob that other functions obey. Works a-OK for me on several different websites. Normally my website's code starts with platform defaults, reads configuration early on, and, if need be, issues setlocale(). Should an error be triggered before the config is applied, it would be handled with default locales; I believe that's the only noticeable downside. Hopefully a rare one ;-)
setlocale() can be switched at run-time, even multiple times if you want. You could imagine running most of the code with user's preferred locale to output UI or report any errors, switching to another locale to format and send message to a foreign customer, and then back to normal settings to continue with outputing UI, all in one pass of PHP.