<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.setlocale.php',
    1 => 'setlocale',
    2 => 'Set locale information',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String Функції',
  ),
  'prev' => 
  array (
    0 => 'function.rtrim.php',
    1 => 'rtrim',
  ),
  'next' => 
  array (
    0 => 'function.sha1.php',
    1 => 'sha1',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/strings/functions/setlocale.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.setlocale" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">setlocale</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">setlocale</span> &mdash; <span class="dc-title">Set locale information</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.setlocale-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>setlocale</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$category</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$locales</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">...$rest</code></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="simpara">Alternative signature (not supported with named arguments):</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>setlocale</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$category</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$locale_array</code></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Sets locale information.
  </p>
  <div class="warning"><strong class="warning">Увага</strong>
   <p class="para">
    The locale information is maintained per process, not per thread. If you
    are running PHP on a multithreaded server API
    , you may experience sudden changes in locale settings while a
    script is running, though the script itself never called 
    <span class="function"><strong>setlocale()</strong></span>. This happens due to other scripts
    running in different threads of the same process at the same time,
    changing the process-wide locale using <span class="function"><strong>setlocale()</strong></span>.
    On Windows, locale information is maintained per thread as of PHP 7.0.5.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.setlocale-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">category</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">category</code> is a named constant specifying the
       category of the functions affected by the locale setting:
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="string.constants.php#constant.lc-all">LC_ALL</a></code></strong> for all of the below
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="string.constants.php#constant.lc-collate">LC_COLLATE</a></code></strong> for string comparison, see
          <span class="function"><a href="function.strcoll.php" class="function">strcoll()</a></span>
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="string.constants.php#constant.lc-ctype">LC_CTYPE</a></code></strong> for character classification and conversion, for
          example <span class="function"><a href="function.ctype-alpha.php" class="function">ctype_alpha()</a></span>
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="string.constants.php#constant.lc-monetary">LC_MONETARY</a></code></strong> for <span class="function"><a href="function.localeconv.php" class="function">localeconv()</a></span>
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="string.constants.php#constant.lc-numeric">LC_NUMERIC</a></code></strong> for decimal separator (See also
          <span class="function"><a href="function.localeconv.php" class="function">localeconv()</a></span>)
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="string.constants.php#constant.lc-time">LC_TIME</a></code></strong> for date and time formatting with
          <span class="function"><a href="function.strftime.php" class="function">strftime()</a></span>
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="string.constants.php#constant.lc-messages">LC_MESSAGES</a></code></strong> for system responses (available if PHP was compiled with
          <code class="literal">libintl</code>)
         </span>
        </li>
       </ul>
      </p>
     </dd>
    
    
     <dt><code class="parameter">locales</code></dt>
     <dd>
      <p class="para">
       If <code class="parameter">locales</code> is the empty string
       <code class="literal">&quot;&quot;</code> or is <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, the locale names will be set from the
       values of environment variables with the same names as the above
       categories, or from &quot;LANG&quot;.
      </p>
      <p class="para">
       If <code class="parameter">locales</code> is <code class="literal">&quot;0&quot;</code>,
       the locale setting is not affected, only the current setting is returned.
      </p>
      <p class="para">
       If <code class="parameter">locales</code> is followed by additional
       parameters then each parameter is tried to be set as
       new locale until success. This is useful if a locale is known under
       different names on different systems or for providing a fallback
       for a possibly not available locale.
      </p>
     </dd>
    
    
     <dt><code class="parameter">rest</code></dt>
     <dd>
      <p class="para">
       Optional string parameters to try as locale settings until
       success.
      </p>
     </dd>
    
    
     <dt><code class="parameter">locale_array</code></dt>
     <dd>
      <p class="para">
       Each array element is tried to be set as
       new locale until success. This is useful if a locale is known under
       different names on different systems or for providing a fallback
       for a possibly not available locale.
      </p>
     </dd>
    
   </dl>
   <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
    <p class="para">
     On Windows, setlocale(LC_ALL, &#039;&#039;) sets the locale names from the
     system&#039;s regional/language settings (accessible via Control Panel).
    </p>
   </p></blockquote>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.setlocale-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns the new current locale, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if the locale functionality is
   not implemented on your platform, the specified locale does not exist or
   the category name is invalid.
  </p>
  <p class="para">
   An invalid category name also causes a warning message. Category/locale
   names can be found in <a href="https://datatracker.ietf.org/doc/html/rfc1766" class="link external">&raquo;&nbsp;RFC 1766</a>
   and <a href="http://www.loc.gov/standards/iso639-2/php/code_list.php" class="link external">&raquo;&nbsp;ISO 639</a>.
   Different systems have different naming schemes for locales.
  </p>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    The return value of <span class="function"><strong>setlocale()</strong></span> depends
    on the system that PHP is running.  It returns exactly
    what the system <code class="literal">setlocale</code> function returns.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 examples" id="refsect1-function.setlocale-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>setlocale()</strong></span> Examples</strong></p>
    <div class="example-contents">
<div class="annotation-non-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Set locale to Dutch */<br /></span><span style="color: #0000BB">setlocale</span><span style="color: #007700">(</span><span style="color: #0000BB">LC_ALL</span><span style="color: #007700">, </span><span style="color: #DD0000">'nl_NL'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Output: vrijdag 22 december 1978 */<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">strftime</span><span style="color: #007700">(</span><span style="color: #DD0000">"%A %e %B %Y"</span><span style="color: #007700">, </span><span style="color: #0000BB">mktime</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">12</span><span style="color: #007700">, </span><span style="color: #0000BB">22</span><span style="color: #007700">, </span><span style="color: #0000BB">1978</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">/* try different possible locale names for german */<br /></span><span style="color: #0000BB">$loc_de </span><span style="color: #007700">= </span><span style="color: #0000BB">setlocale</span><span style="color: #007700">(</span><span style="color: #0000BB">LC_ALL</span><span style="color: #007700">, </span><span style="color: #DD0000">'de_DE@euro'</span><span style="color: #007700">, </span><span style="color: #DD0000">'de_DE'</span><span style="color: #007700">, </span><span style="color: #DD0000">'de'</span><span style="color: #007700">, </span><span style="color: #DD0000">'ge'</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Preferred locale for german on this system is '</span><span style="color: #0000BB">$loc_de</span><span style="color: #DD0000">'"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Приклад #2 <span class="function"><strong>setlocale()</strong></span> Retrieve current setting</strong></p>
    <div class="example-contents">
<div class="annotation-non-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Retrieve current setting */<br /></span><span style="color: #0000BB">$current </span><span style="color: #007700">= </span><span style="color: #0000BB">setlocale</span><span style="color: #007700">(</span><span style="color: #0000BB">LC_ALL</span><span style="color: #007700">, </span><span style="color: #0000BB">null</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"Current locale '</span><span style="color: #0000BB">$current</span><span style="color: #DD0000">'"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-3">
    <p><strong>Приклад #3 <span class="function"><strong>setlocale()</strong></span> Examples for Windows</strong></p>
    <div class="example-contents">
<div class="annotation-non-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Set locale to Dutch */<br /></span><span style="color: #0000BB">setlocale</span><span style="color: #007700">(</span><span style="color: #0000BB">LC_ALL</span><span style="color: #007700">, </span><span style="color: #DD0000">'nld_nld'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Output: vrijdag 22 december 1978 */<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">strftime</span><span style="color: #007700">(</span><span style="color: #DD0000">"%A %d %B %Y"</span><span style="color: #007700">, </span><span style="color: #0000BB">mktime</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">12</span><span style="color: #007700">, </span><span style="color: #0000BB">22</span><span style="color: #007700">, </span><span style="color: #0000BB">1978</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">/* try different possible locale names for german */<br /></span><span style="color: #0000BB">$loc_de </span><span style="color: #007700">= </span><span style="color: #0000BB">setlocale</span><span style="color: #007700">(</span><span style="color: #0000BB">LC_ALL</span><span style="color: #007700">, </span><span style="color: #DD0000">'de_DE@euro'</span><span style="color: #007700">, </span><span style="color: #DD0000">'de_DE'</span><span style="color: #007700">, </span><span style="color: #DD0000">'deu_deu'</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Preferred locale for german on this system is '</span><span style="color: #0000BB">$loc_de</span><span style="color: #DD0000">'"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.setlocale-notes">
  <h3 class="title">Примітки</h3>
  <div class="tip"><strong class="tip">Підказка</strong>
   <p class="para">
    Windows users will find useful information about
    <code class="parameter">locales</code> strings at Microsoft&#039;s
    <abbr title="Microsoft Developer Network">MSDN</abbr> website. Supported language strings can be found
    in the
    <a href="http://msdn.microsoft.com/en-us/library/39cwe7zf.aspx" class="link external">&raquo;&nbsp;language strings documentation</a>
    and supported country/region strings in the
    <a href="http://msdn.microsoft.com/en-us/library/cdax410z.aspx" class="link external">&raquo;&nbsp;country/region strings documentation</a>.
   </p>
  </div>
 </div>


</div><?php manual_footer($setup); ?>