<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Get data from the bundle</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="resourcebundle.geterrormessage.html">ResourceBundle::getErrorMessage</a></div> <div class="next" style="text-align: right; float: right;"><a href="resourcebundle.locales.html">ResourceBundle::getLocales</a></div> <div class="up"><a href="class.resourcebundle.html">ResourceBundle</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="resourcebundle.get" class="refentry"> <div class="refnamediv"> <h1 class="refname">ResourceBundle::get</h1> <h1 class="refname">resourcebundle_get</h1> <p class="verinfo">(PHP >= 5.3.2, PECL intl >= 2.0.0)</p><p class="refpurpose"><span class="refname">ResourceBundle::get</span> -- <span class="refname">resourcebundle_get</span> — <span class="dc-title">Get data from the bundle</span></p> </div> <div class="refsect1 description" id="refsect1-resourcebundle.get-description"> <h3 class="title">Description</h3> <p class="para"> Object oriented style </p> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>ResourceBundle::get</strong></span> ( <span class="methodparam"><span class="type"><span class="type string|int">string|int</span></span> <code class="parameter">$index</code></span> )</div> <p class="para rdfs-comment"> Procedural style </p> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>resourcebundle_get</strong></span> ( <span class="methodparam"><span class="type"><a href="class.resourcebundle.html" class="type ResourceBundle">ResourceBundle</a></span> <code class="parameter">$r</code></span> , <span class="methodparam"><span class="type"><span class="type string|int">string|int</span></span> <code class="parameter">$index</code></span> )</div> <p class="para rdfs-comment"> Get the data from the bundle by index or string key. </p> </div> <div class="refsect1 parameters" id="refsect1-resourcebundle.get-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">r</code></em></span> <dd> <p class="para"> <a href="class.resourcebundle.html" class="classname">ResourceBundle</a> object. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">index</code></em></span> <dd> <p class="para"> Data index, must be string or integer. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-resourcebundle.get-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the data located at the index or <strong><code>NULL</code></strong> on error. Strings, integers and binary data strings are returned as corresponding PHP types, integer array is returned as PHP array. Complex types are returned as <a href="class.resourcebundle.html" class="classname">ResourceBundle</a> object. </p> </div> <div class="refsect1 examples" id="refsect1-resourcebundle.get-examples"> <h3 class="title">Examples</h3> <div class="example" id="example-2673"> <p><strong>Example #1 <span class="function"><strong>resourcebundle_get()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$r </span><span style="color: #007700">= </span><span style="color: #0000BB">resourcebundle_create</span><span style="color: #007700">( </span><span style="color: #DD0000">'es'</span><span style="color: #007700">, </span><span style="color: #DD0000">"/usr/share/data/myapp"</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">resourcebundle_get</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">, </span><span style="color: #DD0000">'somestring'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> <div class="example" id="example-2674"> <p><strong>Example #2 OO example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$r </span><span style="color: #007700">= new </span><span style="color: #0000BB">ResourceBundle</span><span style="color: #007700">( </span><span style="color: #DD0000">'es'</span><span style="color: #007700">, </span><span style="color: #DD0000">"/usr/share/data/myapp"</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$r</span><span style="color: #007700">-></span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'somestring'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> ?Hola, mundo! </pre></div> </div> </div> </div> <div class="refsect1 seealso" id="refsect1-resourcebundle.get-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="resourcebundle.count.html" class="function" rel="rdfs-seeAlso">resourcebundle_count()</a> - Get number of elements in the bundle</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="resourcebundle.geterrormessage.html">ResourceBundle::getErrorMessage</a></div> <div class="next" style="text-align: right; float: right;"><a href="resourcebundle.locales.html">ResourceBundle::getLocales</a></div> <div class="up"><a href="class.resourcebundle.html">ResourceBundle</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>