downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the Git repository for this website on git.php.net.

Source of: /manual/pt_BR/function.yaml-parse.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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 => 'pt_BR',
  ),
 
'this' =>
  array (
   
0 => 'function.yaml-parse.php',
   
1 => 'yaml_parse',
  ),
 
'up' =>
  array (
   
0 => 'ref.yaml.php',
   
1 => 'Yaml Fun&ccedil;&otilde;es',
  ),
 
'prev' =>
  array (
   
0 => 'function.yaml-parse-url.php',
   
1 => 'yaml_parse_url',
  ),
 
'next' =>
  array (
   
0 => 'book.yaf.php',
   
1 => 'Yaf',
  ),
 
'alternatives' =>
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<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">Parse a YAML stream</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.yaml-parse-description">
  <h3 class="title">Descrição</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="language.pseudo-types.php#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>yaml_parse</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$input</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$pos</code><span class="initializer"> = 0</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$ndocs</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$callbacks</code></span>
  ]]] )</div>

  <p class="para rdfs-comment">
   Convert all or part of a YAML document stream to a PHP variable.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.yaml-parse-parameters">
  <h3 class="title">Parâmetros</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">input</code></em></span>
     <dd>

      <p class="para">
       The <span class="type"><a href="language.types.string.php" class="type string">string</a></span> to parse as a YAML document stream.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">pos</code></em></span>
     <dd>

      <p class="para">
       Document to extract from stream (<em>-1</em> for all
       documents, <em>0</em> for first document, ...).
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">ndocs</code></em></span>
     <dd>

      <p class="para">
       If <em><code class="parameter">ndocs</code></em> is provided, then it is filled with the
       number of documents found in stream.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">callbacks</code></em></span>
     <dd>

      <p class="para">
       Content handlers for YAML nodes. Associative <span class="type"><a href="language.types.array.php" class="type array">array</a></span> of YAML
       tag =&gt; <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> mappings. See
       <a href="yaml.callbacks.parse.php" class="link">parse callbacks</a> for more
       details.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.yaml-parse-returnvalues">
  <h3 class="title">Valor Retornado</h3>
  <p class="para">
   Returns the value encoded in <em><code class="parameter">input</code></em> in appropriate
   PHP type ou <strong><code>FALSE</code></strong> em caso de falha. If <em><code class="parameter">pos</code></em> is <em>-1</em> an
   <span class="type"><a href="language.types.array.php" class="type array">array</a></span> will be returned with one entry for each document found
   in the stream.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.yaml-parse-examples">
  <h3 class="title">Exemplos</h3>
  <p class="para">
   <div class="example" id="example-3561">
    <p><strong>Exemplo #1  <span class="function"><strong>yaml_parse()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$yaml&nbsp;</span><span style="color: #007700">=&nbsp;&lt;&lt;&lt;EOD<br /></span><span style="color: #DD0000">---<br />invoice:&nbsp;34843<br />date:&nbsp;"2001-01-23"<br />bill-to:&nbsp;&amp;id001<br />&nbsp;&nbsp;given:&nbsp;Chris<br />&nbsp;&nbsp;family:&nbsp;Dumars<br />&nbsp;&nbsp;address:<br />&nbsp;&nbsp;&nbsp;&nbsp;lines:&nbsp;|-<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;458&nbsp;Walkman&nbsp;Dr.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Suite&nbsp;#292<br />&nbsp;&nbsp;&nbsp;&nbsp;city:&nbsp;Royal&nbsp;Oak<br />&nbsp;&nbsp;&nbsp;&nbsp;state:&nbsp;MI<br />&nbsp;&nbsp;&nbsp;&nbsp;postal:&nbsp;48046<br />ship-to:&nbsp;*id001<br />product:<br />-&nbsp;sku:&nbsp;BL394D<br />&nbsp;&nbsp;quantity:&nbsp;4<br />&nbsp;&nbsp;description:&nbsp;Basketball<br />&nbsp;&nbsp;price:&nbsp;450<br />-&nbsp;sku:&nbsp;BL4438H<br />&nbsp;&nbsp;quantity:&nbsp;1<br />&nbsp;&nbsp;description:&nbsp;Super&nbsp;Hoop<br />&nbsp;&nbsp;price:&nbsp;2392<br />tax:&nbsp;251.420000<br />total:&nbsp;4443.520000<br />comments:&nbsp;Late&nbsp;afternoon&nbsp;is&nbsp;best.&nbsp;Backup&nbsp;contact&nbsp;is&nbsp;Nancy&nbsp;Billsmer&nbsp;@&nbsp;338-4338.<br />...<br /></span><span style="color: #007700">EOD;<br /><br /></span><span style="color: #0000BB">$parsed&nbsp;</span><span style="color: #007700">=&nbsp;</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>O exemplo acima irá imprimir
algo similar à:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
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 seealso" id="refsect1-function.yaml-parse-seealso">
  <h3 class="title">Veja Também</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.yaml-parse-file.php" class="function" rel="rdfs-seeAlso">yaml_parse_file()</a> - Parse a YAML stream from a file</span></li>
    <li class="member"> <span class="function"><a href="function.yaml-parse-url.php" class="function" rel="rdfs-seeAlso">yaml_parse_url()</a> - Parse a Yaml stream from a URL</span></li>
    <li class="member"> <span class="function"><a href="function.yaml-emit.php" class="function" rel="rdfs-seeAlso">yaml_emit()</a> - Returns the YAML representation of a value</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites