<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.yaf-config-simple.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'yaf-config-simple.get.php',
    1 => 'Yaf_Config_Simple::get',
    2 => '获取配置值',
  ),
  'up' => 
  array (
    0 => 'class.yaf-config-simple.php',
    1 => 'Yaf_Config_Simple',
  ),
  'prev' => 
  array (
    0 => 'yaf-config-simple.current.php',
    1 => 'Yaf_Config_Simple::current',
  ),
  'next' => 
  array (
    0 => 'yaf-config-simple.isset.php',
    1 => 'Yaf_Config_Simple::__isset',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/yaf/yaf_config_simple/get.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yaf-config-simple.get" class="refentry">
 <div class="refnamediv">
<h1 class="refname">Yaf_Config_Simple::get</h1>
<p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_Config_Simple::get</span> &mdash; <span class="dc-title">获取配置值</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-config-simple.get-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">function</span> <span class="methodname"><strong>Yaf_Config_Simple::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 class="initializer"> = NULL</span></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>

  <p class="simpara">根据名称获取配置值。如果省略 <code class="parameter">name</code> 或其值为 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>，则返回配置对象本身。</p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-config-simple.get-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">name</code></dt>
    <dd>
<p class="simpara">要获取的配置键。</p>
    </dd>
   
  </dl>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-yaf-config-simple.get-returnvalues">
  <h3 class="title">返回值</h3>
<p class="simpara">返回 <code class="parameter">name</code> 对应的值。数组类型的值会被包装为 <span class="classname"><a href="class.yaf-config-simple.php" class="classname">Yaf_Config_Simple</a></span> 对象。如果键不存在返回 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>；当 <code class="parameter">name</code> 为 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> 时返回配置对象本身。</p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-config-simple.get-examples">
  <h3 class="title">示例</h3>
  <div class="example" id="example-1">
   <p><strong>示例 #1 <span class="methodname"><strong>Yaf_Config_Simple::get()</strong></span> 示例</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php
$config </span><span style="color: #007700">= new </span><span style="color: #0000BB">Yaf_Config_Simple</span><span style="color: #007700">([
    </span><span style="color: #DD0000">'application' </span><span style="color: #007700">=&gt; [</span><span style="color: #DD0000">'name' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'MyApp'</span><span style="color: #007700">],
    </span><span style="color: #DD0000">'database'    </span><span style="color: #007700">=&gt; [</span><span style="color: #DD0000">'host' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">],
]);

</span><span style="color: #FF8000">// 数组类型的值会被包装为 Yaf_Config_Simple 对象
</span><span style="color: #007700">echo </span><span style="color: #0000BB">$config</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'database'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">host</span><span style="color: #007700">, </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;
echo </span><span style="color: #0000BB">$config</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'application'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">name</span><span style="color: #007700">, </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$config</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'missing'</span><span style="color: #007700">));
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

   <div class="example-contents"><p>以上示例的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">localhost
MyApp
NULL</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yaf-config-simple.get-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="yaf-config-simple.set.php" class="methodname" rel="rdfs-seeAlso">Yaf_Config_Simple::set()</a> - 设置配置值</span></li>
   <li><span class="methodname"><a href="yaf-config-simple.toarray.php" class="methodname" rel="rdfs-seeAlso">Yaf_Config_Simple::toArray()</a> - 以数组形式导出配置</span></li>
  </ul>
 </div>

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