PHP Saturday, April 07, 2001  
downloads | documentation | faq | support | reporting bugs | links 

search for in the  

lookup:
PHP HandbuchPHP Handbuch
StringsStrings
 AddCSlashesAddCSlashes
 AddSlashesAddSlashes
 bin2hexbin2hex
 ChopChop
 ChrChr
 chunk_splitchunk_split
 convert_cyr_stringconvert_cyr_string
 count_charscount_chars
 crc32crc32
 cryptcrypt
 echoecho
 explodeexplode
 get_html_translation_tableget_html_translation_table
 get_meta_tagsget_meta_tags
 hebrevhebrev
 hebrevchebrevc
 htmlentitieshtmlentities
 htmlspecialcharshtmlspecialchars
 implodeimplode
 joinjoin
 levenshteinlevenshtein
 ltrimltrim
 md5md5
 MetaphoneMetaphone
 nl2brnl2br
 OrdOrd
 parse_strparse_str
 printprint
 printfprintf
 quoted_printable_decodequoted_printable_decode
 QuoteMetaQuoteMeta
 rtrimrtrim
 sscanfsscanf
 setlocalesetlocale
 similar_textsimilar_text
 soundexsoundex
 sprintfsprintf
 strcasecmpstrcasecmp
 strchrstrchr
 strcmpstrcmp
 strcspnstrcspn
 strip_tagsstrip_tags
 StripCSlashesStripCSlashes
 StripSlashesStripSlashes
 stristrstristr
 strlenstrlen
 strnatcmpstrnatcmp
 strnatcasecmpstrnatcasecmp
 strncmpstrncmp
 str_padstr_pad
 strposstrpos
 strrchrstrrchr
 str_repeatstr_repeat
 strrevstrrev
 strrposstrrpos
 strspnstrspn
 strstrstrstr
 strtokstrtok
 strtolowerstrtolower
 strtoupperstrtoupper
 str_replacestr_replace
 strtrstrtr
 substrsubstr
 substr_countsubstr_count
 substr_replacesubstr_replace
 trimtrim
 ucfirstucfirst
 ucwordsucwords
 wordwrapwordwrap

previoussscanf
similar_textnext

Last updated: Wed, 04 Apr 2001
view this page in English | Brazilian Portuguese | Czech | Dutch | French | German | Hungarian | Italian | Japanese | Korean | Spanish | Plain HTML

setlocale

(PHP 3, PHP 4 )

setlocale -- Setzt lokale Informationen

Beschreibung:

string setlocale (string category, string locale)

Der String category enthält die Kategorie der zu ändernden Lokalitäts-Informationen:

  • LC_ALL - alle folgenden Werte

  • LC_COLLATE - für String-Vergleiche - z.Zt. noch nicht in PHP implementiert

  • LC_CTYPE - betrifft Klassifizierungen und Umwandlung, z.B. bei strtoupper()

  • LC_MONETARY - betrifft localeconv() - z.Zt. noch nicht in PHP implementiert

  • LC_NUMERIC - für das Dezimal-Trennzeichen

  • LC_TIME - betrifft Zeit und Datums-Formatierungen durch strftime()

Ist locale als Leer-String definiert, also "", werden die Werte an Hand der entsprechenden Umgebungs-Variablen gleichen Namens oder von "LANG" bestimmt.

Ist locale Null oder "0", werden keine Einstellungen verändert sondern als Ergebnis zurück gegeben.

Setlocale() gibt die neue Einstellung oder false (wenn die locale-Funktionalität auf der System-Plattform nicht unterstützt wird oder der Kategorie-Wert ungültig ist) zurück. Ein ungültiger Kategorie-Name erzeugt auch noch eine Warnmeldung.

User Contributed Notes: setlocale
Michal Fita <manveru@witrynka.pl>
11-Jan-1999 11:41
It is written nowhere, that setlocale() can be used for simple mathematical operations like adding, substracting, dividing or multiplying. The code below gives correct results:

setlocale("LC_ALL", "pl");
$net = "1234,56";
$gross = "1,22" * $net;
printf("gross: %s, net: %s", $gross, $net");
/* Polish VAT tax is 22% */

Result of this code is:
gross: 1234,56, net: 1506,1632
So, every one can use his own decimal point for mathematical operations without any error or warning (PHP3.0.3).

Lucas Thompson <lucas@slf.cx>
31-Jan-2000 02:57
The Open Group has an excellent document available on the setlocale() library function, most of which applies to the PHP function of the same name.

http://www.opengroup.org/onlinepubs/7908799/xbd/locale.html

WARNING: This document might be a little too complex for people who came from HTML to PHP.

If you migrated from the world of C programming you'll be a locale master after reading this document.

Morgan Christiansson &lt;mog@linux.nu&gt;
29-Mar-2000 12:56
check /usr/share/locale/ if you want more info about the locale available with your *NIX box

there is also a file called /usr/share/locale/locale.alias with a list of aliases
such as swedish for sv_SE

so on all boxes i have accounts on (rh 6.0 and slack 3.4) you can just use setlocale("LC_ALL","swedish"); or other prefered language in plain english.

However, the weekdays were in all lowercase :(

Note: export LC_ALL=swedish made a lot of programs swedish for me, it's also possible to make them russian or japanese :)

menthos@menthos.com
15-Jul-2000 07:40
I used setlocale and then strftime like this:

setlocale('LC_TIME','swedish');
echo strftime("%A",$timestamp);

Works prefectly under Windows.

noog@libero.it
23-Nov-2000 03:13
On windows:
Control Panel->International Settings
You can set your locale and customize it
And locale-related PHP functions work perfectly

Fabian.Rodriguez@toxik.com
14-Dec-2000 07:19
Language information is defined by this RFC:
RFC1766 - Tags for the Identification of Languages - http://www.ietf.org/rfc/rfc1766.txt

And the 2 letter codes come from:
ISO639: "Code for the representation of names of languages" - http://www.w3.org/WAI/ER/IG/ert/iso639.htm
ISO3166-1: "English country names and code elements" - http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/index.html

Also note that the language name can be used in full (ex: setlocale('LC_TIME','swedish'); ) . This full name comes from the latest mentioned file.

Fabian.Rodriguez@toxik.com
14-Dec-2000 07:20
BTW, not all locales are always supported on every server. Ask you ISP/network admin to see if they are.
previoussscanf
similar_textnext

Last updated: Wed, 04 Apr 2001
add note | about notes

show source | credits | stats | mirror sites:  

Copyright © 1998-2001 The PHP Group
All rights reserved.
This mirror generously provided by: chek.com
Last updated: Thu Apr 5 15:50:02 2001 EDT