Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 7525

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>locale_set_default</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="i18n 函数"
HREF="ref.i18n.html"><LINK
REL="PREVIOUS"
TITLE="locale_get_default"
HREF="function.locale-get-default.html"><LINK
REL="NEXT"
TITLE="IBM Functions (PDO_IBM)"
HREF="ref.pdo-ibm.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.locale-get-default.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="ref.pdo-ibm.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.locale-set-default"
></A
>locale_set_default</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN78966"
></A
><P
>    (no version information, might be only in CVS)</P
>locale_set_default&nbsp;--&nbsp;Set the default Locale</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN78969"
></A
><H2
>说明</H2
>bool <B
CLASS="methodname"
>locale_set_default</B
> ( string name )<BR
></BR
><P
>&#13;   Sets the default Locale for PHP programs. Please note that this has nothing
   to do with <A
HREF="function.setlocale.html"
><B
CLASS="function"
>setlocale()</B
></A
> nor with the system locale.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN78979"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>name</CODE
></DT
><DD
><P
>&#13;       The new Locale name. A comprehensive list of the supported locales is
       available at <A
HREF="http://www-950.ibm.com/software/globalization/icu/demo/locales/en/?d_=en"
TARGET="_top"
>http://www-950.ibm.com/software/globalization/icu/demo/locales/en/?d_=en</A
>.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN78989"
></A
><H2
>返回值</H2
><P
>&#13;   如果成功则返回 <TT
CLASS="constant"
><B
>TRUE</B
></TT
>,失败则返回 <TT
CLASS="constant"
><B
>FALSE</B
></TT
>。
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN78994"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN78997"
></A
><P
><B
>例 1. A <B
CLASS="function"
>locale_set_default()</B
> example</B
></P
><P
>&#13;     This example demonstrates a possible usage of
     <B
CLASS="function"
>locale_set_default()</B
> to localize the
     <A
HREF="function.sort.html"
><B
CLASS="function"
>sort()</B
></A
> functions.
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br /></font><font color="#FF8000">// the list of the strings to sort<br /></font><font color="#0000BB">$array </font><font color="#007700">= array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'caramelo'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'cacto'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'caçada'<br /></font><font color="#007700">);<br /><br /></font><font color="#FF8000">// set our locale (Portuguese, in this case)<br /></font><font color="#0000BB">locale_set_default</font><font color="#007700">(</font><font color="#DD0000">'pt_PT'</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// sort using the locale we previously set<br /></font><font color="#0000BB">sort</font><font color="#007700">(</font><font color="#0000BB">$array</font><font color="#007700">, </font><font color="#0000BB">SORT_LOCALE_STRING</font><font color="#007700">);<br /><br /></font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">$array</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例将输出:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>Array
(
    [0] =&#62; caçada
    [1] =&#62; cacto
    [2] =&#62; caramelo
)</PRE
></TD
></TR
></TABLE
><P
>&#13;     If we didn't use the locale, PHP would sort the string using the ASCII
     characters value, thus returning (wrongly):
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>Array
(
    [0] =&#62; cacto
    [1] =&#62; caramelo
    [2] =&#62; caçada
)</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN79008"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.locale-get-default.html"
><B
CLASS="function"
>locale_get_default()</B
></A
></TD
></TR
></TBODY
></TABLE
><P
></P
>
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.locale-get-default.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="ref.pdo-ibm.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>locale_get_default</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.i18n.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>IBM Functions (PDO_IBM)</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>