RE: [PHP] setlocale() changes?
| From: | Ford, Mike [LSS] | Date: | Thu, 05 Jun 2003 11:45:59 +0000 |
| Subject: | RE: [PHP] setlocale() changes? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-150326@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: CPT John W. Holmes [mailto:holmes072000@charter.net]
> Sent: 04 June 2003 14:33
>
> > I've been getting a warning on one of my scripts since I
> upgraded from
> 4.1.2
> > to the most recent version of PHP. The warning is:
> >
> > Warning: setlocale(): Passing locale category name as string is
> deprecated.
> > Use the LC_* -constants instead
> >
> >
> > The script at the line that is failing sez:
> >
> > setlocale ("LC_TIME", "$locale");
>
> "LC_TIME" is a string... LC_TIME is a constant...
>
> Like the warning says, use a constant.
Also remove the quotes round $locale -- why force PHP to do the extra work of decoding the string
and *then* deciding it needs to fetch the value of $locale, when you can just ask it to fetch the
value directly?
setlocale (LC_TIME, $locale);
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211