<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.yaml.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.yaml-emit.php',
    1 => 'yaml_emit',
    2 => 'Returns the YAML representation of a value',
  ),
  'up' => 
  array (
    0 => 'ref.yaml.php',
    1 => 'Yaml 函数',
  ),
  'prev' => 
  array (
    0 => 'ref.yaml.php',
    1 => 'Yaml 函数',
  ),
  'next' => 
  array (
    0 => 'function.yaml-emit-file.php',
    1 => 'yaml_emit_file',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yaml/functions/yaml-emit.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.yaml-emit" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">yaml_emit</h1>
  <p class="verinfo">(PECL yaml &gt;= 0.5.0)</p><p class="refpurpose"><span class="refname">yaml_emit</span> &mdash; <span class="dc-title">Returns the YAML representation of a value</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.yaml-emit-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>yaml_emit</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$data</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$encoding</code><span class="initializer"> = YAML_ANY_ENCODING</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$linebreak</code><span class="initializer"> = YAML_ANY_BREAK</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$callbacks</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span><br>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   Generate a YAML representation of the provided <code class="parameter">data</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.yaml-emit-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">data</code></dt>
     <dd>
      <p class="para">
       The <code class="parameter">data</code> being encoded. Can be any type except
       a <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">encoding</code></dt>
     <dd>
      <p class="para">
       Output character encoding chosen from
       <strong><code><a href="yaml.constants.php#constant.yaml-any-encoding">YAML_ANY_ENCODING</a></code></strong>,
       <strong><code><a href="yaml.constants.php#constant.yaml-utf8-encoding">YAML_UTF8_ENCODING</a></code></strong>,
       <strong><code><a href="yaml.constants.php#constant.yaml-utf16le-encoding">YAML_UTF16LE_ENCODING</a></code></strong>,
       <strong><code><a href="yaml.constants.php#constant.yaml-utf16be-encoding">YAML_UTF16BE_ENCODING</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">linebreak</code></dt>
     <dd>
      <p class="para">
       Output linebreak style chosen from
       <strong><code><a href="yaml.constants.php#constant.yaml-any-break">YAML_ANY_BREAK</a></code></strong>,
       <strong><code><a href="yaml.constants.php#constant.yaml-cr-break">YAML_CR_BREAK</a></code></strong>,
       <strong><code><a href="yaml.constants.php#constant.yaml-ln-break">YAML_LN_BREAK</a></code></strong>,
       <strong><code><a href="yaml.constants.php#constant.yaml-crln-break">YAML_CRLN_BREAK</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">callbacks</code></dt>
     <dd>
      <p class="para">
       Content handlers for emitting YAML nodes. Associative <span class="type"><a href="language.types.array.php" class="type array">array</a></span>
       of classname =&gt; <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> mappings. See
       <a href="yaml.callbacks.emit.php" class="link">emit callbacks</a> for more
       details.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.yaml-emit-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a YAML encoded <span class="type"><a href="language.types.string.php" class="type string">string</a></span> on success.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.yaml-emit-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL yaml 1.1.0</td>
       <td>
        The <code class="parameter">callbacks</code> parameter was added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.yaml-emit-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-4125">
    <p><strong>示例 #1 <span class="function"><strong>yaml_emit()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$addr </span><span style="color: #007700">= array(<br />    </span><span style="color: #DD0000">"given" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"Chris"</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"family"</span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"Dumars"</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"address"</span><span style="color: #007700">=&gt; array(<br />        </span><span style="color: #DD0000">"lines"</span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"458 Walkman Dr.<br />        Suite #292"</span><span style="color: #007700">,<br />        </span><span style="color: #DD0000">"city"</span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"Royal Oak"</span><span style="color: #007700">,<br />        </span><span style="color: #DD0000">"state"</span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"MI"</span><span style="color: #007700">,<br />        </span><span style="color: #DD0000">"postal"</span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">48046</span><span style="color: #007700">,<br />      ),<br />  );<br /></span><span style="color: #0000BB">$invoice </span><span style="color: #007700">= array (<br />    </span><span style="color: #DD0000">"invoice"</span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">34843</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"date"</span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">980208000</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"bill-to"</span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$addr</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"ship-to"</span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$addr</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"product"</span><span style="color: #007700">=&gt; array(<br />        array(<br />            </span><span style="color: #DD0000">"sku"</span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"BL394D"</span><span style="color: #007700">,<br />            </span><span style="color: #DD0000">"quantity"</span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">4</span><span style="color: #007700">,<br />            </span><span style="color: #DD0000">"description"</span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"Basketball"</span><span style="color: #007700">,<br />            </span><span style="color: #DD0000">"price"</span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">450</span><span style="color: #007700">,<br />          ),<br />        array(<br />            </span><span style="color: #DD0000">"sku"</span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"BL4438H"</span><span style="color: #007700">,<br />            </span><span style="color: #DD0000">"quantity"</span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">1</span><span style="color: #007700">,<br />            </span><span style="color: #DD0000">"description"</span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"Super Hoop"</span><span style="color: #007700">,<br />            </span><span style="color: #DD0000">"price"</span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">2392</span><span style="color: #007700">,<br />          ),<br />      ),<br />    </span><span style="color: #DD0000">"tax"</span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">251.42</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"total"</span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">4443.52</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"comments"</span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."</span><span style="color: #007700">,<br />  );<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">yaml_emit</span><span style="color: #007700">(</span><span style="color: #0000BB">$invoice</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例的输出类似于:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">string(628) &quot;---
invoice: 34843
date: 980208000
bill-to:
  given: Chris
  family: Dumars
  address:
    lines: |-
      458 Walkman Dr.
              Suite #292
    city: Royal Oak
    state: MI
    postal: 48046
ship-to:
  given: Chris
  family: Dumars
  address:
    lines: |-
      458 Walkman Dr.
              Suite #292
    city: Royal Oak
    state: MI
    postal: 48046
product:
- sku: BL394D
  quantity: 4
  description: Basketball
  price: 450
- sku: BL4438H
  quantity: 1
  description: Super Hoop
  price: 2392
tax: 251.420000
total: 4443.520000
comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.
...
&quot;</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.yaml-emit-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.yaml-emit-file.php" class="function" rel="rdfs-seeAlso">yaml_emit_file()</a> - Send the YAML representation of a value to a file</span></li>
    <li><span class="function"><a href="function.yaml-parse.php" class="function" rel="rdfs-seeAlso">yaml_parse()</a> - Parse a YAML stream</span></li>
   </ul>
  </p>
 </div>


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