Re: setlocale Apache/PHP problem - tentative bug.
| From: | Stephen Langasek | Date: | Thu, 07 Oct 1999 01:57:12 +0000 |
| Subject: | Re: setlocale Apache/PHP problem - tentative bug. | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-11591@lists.php.net to get a copy of this message | ||
On Thu, 7 Oct 1999, Jouni Ahto wrote:
> On Wed, 6 Oct 1999, Christian Reis wrote:
> > I infer the problem is:
> > setlocale is [cached,kept] over a session on the httpd process that ran.
> PHP just calls setlocale() in your c-library. setlocale() changes
> permanently the calling programs environment. There is no caching of
> locale in PHP.
> You think right. That's the cause of your problem. Do setlocale("LC_ALL",
> "C") at the end of the page where you changed the locale to pt_BR and
> everything is fine.
The "proper" solution is for PHP's setlocale() function to save the original
locale the first time the function is called in a script, and restore this
locale when PHP cleans up on exit. PHP scripts should not be able to affect
the web server's execution environment in this manner, and it shouldn't be
the script programmer's responsibility to clean up afterwards.
-Steve Langasek
postmodern programmer