<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.yaconf.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'yaconf.get.php',
    1 => 'Yaconf::get',
    2 => 'Retrieve a configuration value by name',
  ),
  'up' => 
  array (
    0 => 'class.yaconf.php',
    1 => 'Yaconf',
  ),
  'prev' => 
  array (
    0 => 'yaconf.debug-info.php',
    1 => 'Yaconf::__debug_info',
  ),
  'next' => 
  array (
    0 => 'yaconf.has.php',
    1 => 'Yaconf::has',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yaconf/yaconf/get.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yaconf.get" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yaconf::get</h1>
  <p class="verinfo">(PECL yaconf &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Yaconf::get</span> &mdash; <span class="dc-title">Retrieve a configuration value by name</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaconf.get-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="modifier">function</span> <span class="methodname"><strong>Yaconf::get</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$name</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$default</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>

  <p class="simpara">
   Retrieves the configuration value stored under
   <code class="parameter">name</code>. Names use dot notation to traverse
   nested keys: <code class="literal">&quot;app&quot;</code> addresses the whole parsed
   <var class="filename">app.ini</var> file,
   <code class="literal">&quot;app.name&quot;</code> a key inside it, and since Yaconf
   1.2.0 <code class="literal">&quot;users.database.master&quot;</code> a key in the
   file <var class="filename">database.ini</var> placed in the
   <var class="filename">users/</var> sub-directory. The dot notation
   supports up to 64 levels of nesting.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaconf.get-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">name</code></dt>
    <dd>
     <p class="simpara">
      The configuration name to look up, using dot notation to
      traverse nested keys, for example
      <code class="literal">&quot;app.name&quot;</code>, <code class="literal">&quot;app.features.1&quot;</code>
      or, since Yaconf 1.2.0, <code class="literal">&quot;users.database.master&quot;</code>
      for files in sub-directories.
     </p>
    </dd>
   
   
    <dt><code class="parameter">default</code></dt>
    <dd>
     <p class="simpara">
      The value to return when <code class="parameter">name</code> is not
      found. When omitted, <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> is returned.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-yaconf.get-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="simpara">
   The stored configuration value, a <span class="type"><a href="language.types.string.php" class="type string">string</a></span> or an
   <span class="type"><a href="language.types.array.php" class="type array">array</a></span>, when <code class="parameter">name</code> exists;
   otherwise the <code class="parameter">default</code> (or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> when no
   default was given).
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaconf.get-examples">
  <h3 class="title">Приклади</h3>
  <p class="simpara">
   The examples below assume the following two files placed in the
   directory configured with <code class="literal">yaconf.directory</code>.
  </p>
  <div class="example-contents">
<div class="inicode"><pre class="inicode">; app.ini
name=&quot;shop&quot;                     ; scalar value
debug=0                         ; number
features[]=&quot;checkout&quot;           ; array entries, both notations
features.1=&quot;wishlist&quot;</pre>
</div>
  </div>

  <div class="example-contents">
<div class="inicode"><pre class="inicode">; users/database.ini, in a sub-directory (Yaconf 1.2.0+)
master=&quot;192.168.0.10&quot;
replica=&quot;192.168.0.20&quot;</pre>
</div>
  </div>

  <div class="example" id="example-1">
   <p><strong>Приклад #1 <span class="methodname"><strong>Yaconf::get()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php
</span><span style="color: #FF8000">// fetch a whole parsed file as an array
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaconf</span><span style="color: #007700">::</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">"app"</span><span style="color: #007700">));

</span><span style="color: #FF8000">// dot notation traverses nested keys
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaconf</span><span style="color: #007700">::</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">"app.name"</span><span style="color: #007700">));           </span><span style="color: #FF8000">// string(4) "shop"
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaconf</span><span style="color: #007700">::</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">"app.features.1"</span><span style="color: #007700">));     </span><span style="color: #FF8000">// string(8) "wishlist"

// since 1.2.0: files in sub-directories are namespaced by the
// directory name
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaconf</span><span style="color: #007700">::</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">"users.database.master"</span><span style="color: #007700">)); </span><span style="color: #FF8000">// string(12) "192.168.0.10"

// when the key is missing, the default is returned
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaconf</span><span style="color: #007700">::</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">"app.missing"</span><span style="color: #007700">));             </span><span style="color: #FF8000">// NULL
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaconf</span><span style="color: #007700">::</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">"app.missing"</span><span style="color: #007700">, </span><span style="color: #DD0000">"fallback"</span><span style="color: #007700">)); </span><span style="color: #FF8000">// string(8) "fallback"
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yaconf.get-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="yaconf.has.php" class="methodname" rel="rdfs-seeAlso">Yaconf::has()</a> - Check whether a configuration value exists</span></li>
    <li><span class="methodname"><a href="yaconf.debug-info.php" class="methodname" rel="rdfs-seeAlso">Yaconf::__debug_info()</a> - Inspect how a configuration value is stored</span></li>
   </ul>
  </p>
 </div>


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