当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > setlocale() 函数

PHP
PHP 安全邮件
MySQL 介绍
连接 MySQL
创建 MySQL
MySQL 插入记录
MySQL 选择记录
MySQL Where
MySQL Order By
MySQL 记录更新
MySQL 删除记录
PHP ODBC
XML Expat Parser
XML SimpleXML
PHP 数组参考
PHP Calendar
PHP Date
PHP Directory
PHP Filesystem
PHP FTP
PHP HTTP

PHP 中的 setlocale() 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 588 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The setlocale() function sets locale information.
setlocale()函数的作用是:设置场景信息。

Locale information is language, monetary, time and other information specific for a geographical area.
本地信息可以是指定的某个区域的语言、货币、时间以及其它的信息。

This function returns the current locale settings, or FALSE on failure.
如果这个函数成功执行,将返回当前的场景属性;如果执行失败,将返回False。

Syntax
语法

setlocale(constant,location)

Parameter参数 Description描述
constant Required. Specifies what locale information should be set.
必要参数。指定需要设置的场景信息

Available constants:
可用的常量:

  • LC_ALL - All of the below
    LC_ALL – 所有下属的常量
  • LC_COLLATE -  Sort order
    LC_COLLATE – 排列顺序
  • LC_CTYPE - Character classification and conversion (e.g. all characters should be lower or upper-case)
    LC_CTYPE – 字符分类和转换(例如:将所有的字符转换成小写或大写形式)
  • LC_MESSAGES - System message formatting
    LC_MESSAGES – 系统信息格式
  • LC_MONETARY - Monetary/currency formatting
    LC_MONETARY – 货币 / 通货格式
  • LC_NUMERIC - Numeric formatting
    LC_NUMERIC – 数值格式
  • LC_TIME - Date and time formatting
    LC_TIME – 日期和时间格式
location Required. Specifies what country/region to set the locale information to. Can be a string or an array. If the location is an array, setlocale() will try each array element until it finds a valid language or region code. This is very useful if a region is known under different names on different systems.
必要参数。指定需要进行场景信息设置的国家或区域。它可以由一个字符串或一个数组组成。如果本地区域是一个数组,那么setlocale()函数将尝试每个数组元素直到它从中获取有效的语言和区域代码信息为止。如果一个区域处于不同操作系统中的不同名称下,那么这个参数将非常有用。

Note: Here you can find language and region codes.
注意:你可以通过下面一个地址查询:语言信息和区域代码



Tips and Notes
提示和注意点

Note: The setlocale() function changes the locale only for the current script.
注意:setlocale()函数进改变当前脚本程序中的场景。

Tip: The locale information can be set to system default with setlocale(LC_ALL,NULL)
提示:可以使用setlocale(LC_ALL,NULL)函数将场景信息设置为系统默认值。


Example
案例

In this example we will set the locale to US English and then back to default again:
在下面这个案例中,我们把场景设置成美国英语[US English]之后,再将转会默认的场景信息:

<?php
echo setlocale(LC_ALL,"En-Us");
echo "<br />";
echo setlocale(LC_ALL,NULL);
?>

The output of the code above will be:
上述代码将输出下面的结果:

English_United States.1252
Norwegian (Bokmål)_Norway.1252

评论 (0) All

登陆 | 还没注册?