<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.yaml-parse.php',
    1 => 'yaml_parse',
    2 => 'YAML ストリームをパースする',
  ),
  'up' => 
  array (
    0 => 'ref.yaml.php',
    1 => 'Yaml 関数',
  ),
  'prev' => 
  array (
    0 => 'function.yaml-emit-file.php',
    1 => 'yaml_emit_file',
  ),
  'next' => 
  array (
    0 => 'function.yaml-parse-file.php',
    1 => 'yaml_parse_file',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/yaml/functions/yaml-parse.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.yaml-parse" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">yaml_parse</h1>
  <p class="verinfo">(PECL yaml &gt;= 0.4.0)</p><p class="refpurpose"><span class="refname">yaml_parse</span> &mdash; <span class="dc-title">YAML ストリームをパースする</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.yaml-parse-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>yaml_parse</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$input</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">$pos</code><span class="initializer"> = 0</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 reference">&$ndocs</code><span class="initializer"> = ?</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.mixed.php" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   YAML ドキュメントストリーム全体あるいはその一部を、PHP の変数に変換します。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.yaml-parse-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">input</code></dt>
     <dd>
      <p class="para">
       YAML ドキュメントストリームとしてパースする文字列。
      </p>
     </dd>
    
    
     <dt><code class="parameter">pos</code></dt>
     <dd>
      <p class="para">
       ストリームから取り出すドキュメント (<code class="literal">-1</code>
       はすべてのドキュメント、<code class="literal">0</code> は最初のドキュメント、...)。
      </p>
     </dd>
    
    
     <dt><code class="parameter">ndocs</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">ndocs</code> を渡すと、
       ストリーム内で見つかったドキュメントの数がそこに格納されます。
      </p>
     </dd>
    
    
     <dt><code class="parameter">callbacks</code></dt>
     <dd>
      <p class="para">
       YAML ノードのコンテンツハンドラ。
       YAML タグ =&gt; <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> 形式の連想配列となります。
       詳細は<a href="yaml.callbacks.parse.php" class="link">パースコールバック</a>
       を参照ください。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.yaml-parse-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   適切な PHP の型に変換した結果を返します。
   失敗した場合に <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
   <code class="parameter">pos</code> が <code class="literal">-1</code> の場合は配列を返します。
   配列の各要素が、ストリーム内で見つかった個々のドキュメントとなります。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.yaml-parse-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 <span class="function"><strong>yaml_parse()</strong></span> の例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$yaml </span><span style="color: #007700">= &lt;&lt;&lt;EOD<br /></span><span style="color: #DD0000">---<br />invoice: 34843<br />date: "2001-01-23"<br />bill-to: &amp;id001<br />  given: Chris<br />  family: Dumars<br />  address:<br />    lines: |-<br />      458 Walkman Dr.<br />              Suite #292<br />    city: Royal Oak<br />    state: MI<br />    postal: 48046<br />ship-to: *id001<br />product:<br />- sku: BL394D<br />  quantity: 4<br />  description: Basketball<br />  price: 450<br />- sku: BL4438H<br />  quantity: 1<br />  description: Super Hoop<br />  price: 2392<br />tax: 251.420000<br />total: 4443.520000<br />comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.<br />...<br /></span><span style="color: #007700">EOD;<br /><br /></span><span style="color: #0000BB">$parsed </span><span style="color: #007700">= </span><span style="color: #0000BB">yaml_parse</span><span style="color: #007700">(</span><span style="color: #0000BB">$yaml</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$parsed</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">array(8) {
  [&quot;invoice&quot;]=&gt;
  int(34843)
  [&quot;date&quot;]=&gt;
  string(10) &quot;2001-01-23&quot;
  [&quot;bill-to&quot;]=&gt;
  &amp;array(3) {
    [&quot;given&quot;]=&gt;
    string(5) &quot;Chris&quot;
    [&quot;family&quot;]=&gt;
    string(6) &quot;Dumars&quot;
    [&quot;address&quot;]=&gt;
    array(4) {
      [&quot;lines&quot;]=&gt;
      string(34) &quot;458 Walkman Dr.
        Suite #292&quot;
      [&quot;city&quot;]=&gt;
      string(9) &quot;Royal Oak&quot;
      [&quot;state&quot;]=&gt;
      string(2) &quot;MI&quot;
      [&quot;postal&quot;]=&gt;
      int(48046)
    }
  }
  [&quot;ship-to&quot;]=&gt;
  &amp;array(3) {
    [&quot;given&quot;]=&gt;
    string(5) &quot;Chris&quot;
    [&quot;family&quot;]=&gt;
    string(6) &quot;Dumars&quot;
    [&quot;address&quot;]=&gt;
    array(4) {
      [&quot;lines&quot;]=&gt;
      string(34) &quot;458 Walkman Dr.
        Suite #292&quot;
      [&quot;city&quot;]=&gt;
      string(9) &quot;Royal Oak&quot;
      [&quot;state&quot;]=&gt;
      string(2) &quot;MI&quot;
      [&quot;postal&quot;]=&gt;
      int(48046)
    }
  }
  [&quot;product&quot;]=&gt;
  array(2) {
    [0]=&gt;
    array(4) {
      [&quot;sku&quot;]=&gt;
      string(6) &quot;BL394D&quot;
      [&quot;quantity&quot;]=&gt;
      int(4)
      [&quot;description&quot;]=&gt;
      string(10) &quot;Basketball&quot;
      [&quot;price&quot;]=&gt;
      int(450)
    }
    [1]=&gt;
    array(4) {
      [&quot;sku&quot;]=&gt;
      string(7) &quot;BL4438H&quot;
      [&quot;quantity&quot;]=&gt;
      int(1)
      [&quot;description&quot;]=&gt;
      string(10) &quot;Super Hoop&quot;
      [&quot;price&quot;]=&gt;
      int(2392)
    }
  }
  [&quot;tax&quot;]=&gt;
  float(251.42)
  [&quot;total&quot;]=&gt;
  float(4443.52)
  [&quot;comments&quot;]=&gt;
  string(68) &quot;Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.&quot;
}</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.yaml-parse-notes">
  <h3 class="title">注意</h3>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    <code class="literal">!php/object</code> タグを使ったノードの
    <span class="function"><a href="function.unserialize.php" class="function">unserialize()</a></span> を有効にしている場合に、
    ユーザーからの信頼できない入力を
    <span class="function"><strong>yaml_parse()</strong></span>
    で処理するのは危険です。
    この挙動を無効にするには、ini 設定の <code class="literal">yaml.decode_php</code> を利用します。
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.yaml-parse-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.yaml-parse-file.php" class="function" rel="rdfs-seeAlso">yaml_parse_file()</a> - ファイルからの YAML ストリームをパースする</span></li>
    <li><span class="function"><a href="function.yaml-parse-url.php" class="function" rel="rdfs-seeAlso">yaml_parse_url()</a> - URL からの YAML ストリームをパースする</span></li>
    <li><span class="function"><a href="function.yaml-emit.php" class="function" rel="rdfs-seeAlso">yaml_emit()</a> - YAML 形式にした値を返す</span></li>
   </ul>
  </p>
 </div>


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