php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #6906 setting locale affects PHP code parser!
Submitted: 2000-09-27 16:40 UTC Modified: 2002-04-01 19:41 UTC
From: jarmoni at poczta dot fm Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.0.2 OS: Windows NT 4
Private report: No CVE-ID: None
 [2000-09-27 16:40 UTC] jarmoni at poczta dot fm
Hi,

          I think I've found something that appears as a bug in PHP. It seems that
          the PHP code is parsed according to the locale set in the very code.

          I came across this BUG in a project I developed recently. I set the locale
          to pl_PL (Polish) in one piece of code. In this locale the decimal symbol
          is represented by coma sign insted of dot.

          In another piece of code, that was REQUIRED (ie. included with require
          instruction) it came out that I couldn't code fraction numbers! In polish,
          fraction numbers are stated with coma -- ie. for example 3,14 instead of
          3.14.

          The PHP parser required me to write fraction numbers with coma (from
          locale), which is already reserved as a list separator.

          The walkaround I found is that you should code fractions using the division
          operation. The other (and much nicier) method would be swiching locale, but
          I haven't found the function to get the locale. So, although there is
          setlocale(), there isn't something like getlocale(). At least as much as I
          know.

          If you want to recreate the bug, write the code:

          setlocale("LC_ALL", "pl_PL");  // you have to have it installed
          print strval(3.14);    // prints "3"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-28 21:21 UTC] jah@php.net
From the documentation of setlocale: "If locale is zero or "0", the locale setting
is not affected, only the current setting is returned." 
 [2002-04-01 19:41 UTC] sniper@php.net
Not a bug and there's nothing to change either.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC