<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/book.intl.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'class.resourcebundle.php',
    1 => 'ResourceBundle',
    2 => 'The ResourceBundle class',
  ),
  'up' => 
  array (
    0 => 'book.intl.php',
    1 => 'intl',
  ),
  'prev' => 
  array (
    0 => 'intldateformatter.settimezone.php',
    1 => 'IntlDateFormatter::setTimeZone',
  ),
  'next' => 
  array (
    0 => 'resourcebundle.count.php',
    1 => 'ResourceBundle::count',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/intl/resourcebundle.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/class.resourcebundle.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="class.resourcebundle" class="reference">
 <h1 class="title">The ResourceBundle class</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 5 &gt;= 5.3.2, PHP 7, PHP 8, PECL intl &gt;= 2.0.0)</p>

  
  <div class="section" id="resourcebundle.intro">
   <h2 class="title">Introduction</h2>
   <p class="simpara">
    Localized software products often require sets of data that are to be customized
    depending on current locale, e.g.: messages, labels, formatting patterns. ICU 
    resource mechanism allows to define sets of resources that the application can 
    load on locale basis, while accessing them in unified locale-independent fashion.
   </p>
   <p class="simpara">
    This class implements access to ICU resource data files. These files are binary data
    arrays which ICU uses to store the localized data. 
   </p>
   <p class="simpara">
    ICU resource bundle can hold simple resources and complex resources. Complex resources
    are containers which can be either integer-indexed or string-indexed (just like PHP arrays).
    Simple resources can be of the following types: string, integer, binary data field 
    or integer array.
   </p>
   <p class="simpara">
    <span class="classname"><strong class="classname">ResourceBundle</strong></span> supports direct access to the data through array access
    pattern and iteration via <a href="control-structures.foreach.php" class="link">foreach</a>,
    as well as access via class methods. The result will be PHP value for simple resources and
    <span class="classname"><strong class="classname">ResourceBundle</strong></span> object for complex ones. All resources are read-only.
   </p>
  </div>
  

  <div class="section" id="resourcebundle.synopsis">
   <h2 class="title">Class synopsis</h2>

   
   <div class="classsynopsis"><div class="classsynopsisinfo">
    
     <span class="modifier">class</span> <strong class="classname"><strong class="classname">ResourceBundle</strong></strong>
    

    
     <span class="modifier">implements</span>
      <a href="class.iteratoraggregate.php" class="interfacename">IteratorAggregate</a>,

     <a href="class.countable.php" class="interfacename">Countable</a> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="resourcebundle.create.php" class="methodname">__construct</a></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">$locale</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">$bundle</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$fallback</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>)</div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="resourcebundle.count.php" class="methodname">count</a></span>(): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="resourcebundle.create.php" class="methodname">create</a></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">$locale</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">$bundle</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$fallback</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.resourcebundle.php" class="type ResourceBundle">ResourceBundle</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="resourcebundle.get.php" class="methodname">get</a></span>(<span class="methodparam"><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.integer.php" class="type int">int</a></span></span> <code class="parameter">$index</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$fallback</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>): <span class="type"><span class="type"><a href="class.resourcebundle.php" class="type ResourceBundle">ResourceBundle</a></span>|<span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="resourcebundle.geterrorcode.php" class="methodname">getErrorCode</a></span>(): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="resourcebundle.geterrormessage.php" class="methodname">getErrorMessage</a></span>(): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="resourcebundle.locales.php" class="methodname">getLocales</a></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$bundle</code></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

   }</div>
   

   <div class="section">
    <h2 class="title">Changelog</h2>
    <table class="doctable informaltable">
     
      <thead>
       <tr>
        <th>Version</th>
        <th>Description</th>
       </tr>

      </thead>

      <tbody class="tbody">
       <tr>
        <td>8.0.0</td>
        <td>
         <span class="classname"><strong class="classname">ResourceBundle</strong></span> implements
         <span class="interfacename"><a href="class.iteratoraggregate.php" class="interfacename">IteratorAggregate</a></span> now.
         Previously, <span class="interfacename"><a href="class.traversable.php" class="interfacename">Traversable</a></span> was implemented instead.
        </td>
       </tr>

       <tr>
        <td>7.4.0</td>
        <td>
         <span class="classname"><strong class="classname">ResourceBundle</strong></span> implements
         <span class="interfacename"><a href="class.countable.php" class="interfacename">Countable</a></span> now.
        </td>
       </tr>

      </tbody>
     
    </table>

   </div>
  </div>



  <div class="section" id="resourcebundle.seealso">
   <h2 class="title">See Also</h2>
   <p class="para">
    <ul class="simplelist">
     <li>
      <a href="https://unicode-org.github.io/icu/userguide/locale/resources.html" class="link external">&raquo;&nbsp;
       ICU Resource Management
      </a>
     </li>
     <li>
      <a href="https://unicode-org.github.io/icu/userguide/icu_data/" class="link external">&raquo;&nbsp;ICU Data</a>
     </li>
    </ul>
   </p>
  </div>
 </div>

 






























<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="resourcebundle.count.php">ResourceBundle::count</a> — Get number of elements in the bundle</li><li><a href="resourcebundle.create.php">ResourceBundle::create</a> — Create a resource bundle</li><li><a href="resourcebundle.get.php">ResourceBundle::get</a> — Get data from the bundle</li><li><a href="resourcebundle.geterrorcode.php">ResourceBundle::getErrorCode</a> — Get bundle's last error code</li><li><a href="resourcebundle.geterrormessage.php">ResourceBundle::getErrorMessage</a> — Get bundle's last error message</li><li><a href="resourcebundle.locales.php">ResourceBundle::getLocales</a> — Get supported locales</li></ul>
</div>
<?php manual_footer($setup); ?>