<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.zookeeper.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'zookeeper.set.php',
    1 => 'Zookeeper::set',
    2 => 'Sets the data associated with a node',
  ),
  'up' => 
  array (
    0 => 'class.zookeeper.php',
    1 => 'Zookeeper',
  ),
  'prev' => 
  array (
    0 => 'zookeeper.isrecoverable.php',
    1 => 'Zookeeper::isRecoverable',
  ),
  'next' => 
  array (
    0 => 'zookeeper.setacl.php',
    1 => 'Zookeeper::setAcl',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/zookeeper/zookeeper/set.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="zookeeper.set" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Zookeeper::set</h1>
  <p class="verinfo">(PECL zookeeper &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">Zookeeper::set</span> &mdash; <span class="dc-title">Sets the data associated with a node</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-zookeeper.set-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><strong>Zookeeper::set</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">$path</code></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">$value</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">$version</code><span class="initializer"> = -1</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 reference">&$stat</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.boolean.php" class="type bool">bool</a></span></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-zookeeper.set-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">path</code></dt>
    <dd>
     <p class="para">
      The name of the node. Expressed as a file name with slashes separating ancestors of the node.
     </p>
    </dd>
   
   
    <dt><code class="parameter">value</code></dt>
    <dd>
     <p class="para">
      The data to be stored in the node.
     </p>
    </dd>
   
   
    <dt><code class="parameter">version</code></dt>
    <dd>
     <p class="para">
      The expected version of the node. The function will fail if the actual version of the node does not match the expected version. If -1 is used the version check will not take place.
     </p>
    </dd>
   
   
    <dt><code class="parameter">stat</code></dt>
    <dd>
     <p class="para">
      If not NULL, will hold the value of stat for the path on return.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-zookeeper.set-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, 或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-zookeeper.set-errors">
  <h3 class="title">错误/异常</h3>
  <p class="para">
   This method emits PHP error/warning when parameters count or types are wrong or fail to save value to node.
  </p>
  <div class="caution"><strong class="caution">警告</strong>
    <p class="para">
      Since version 0.3.0, this method emits <span class="classname"><a href="class.zookeeperexception.php" class="classname">ZookeeperException</a></span> and it&#039;s derivatives.
    </p>
  </div>
 </div>


 <div class="refsect1 examples" id="refsect1-zookeeper.set-examples">
  <h3 class="title">示例</h3>
  <div class="example" id="zookeeper.set.example.basic">
   <p><strong>示例 #1 <span class="methodname"><strong>Zookeeper::set()</strong></span> example</strong></p>
   <div class="example-contents"><p>
     Save value to node.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$zookeeper </span><span style="color: #007700">= new </span><span style="color: #0000BB">Zookeeper</span><span style="color: #007700">(</span><span style="color: #DD0000">'locahost:2181'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$path </span><span style="color: #007700">= </span><span style="color: #DD0000">'/path/to/node'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$value </span><span style="color: #007700">= </span><span style="color: #DD0000">'nodevalue'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= </span><span style="color: #0000BB">$zookeeper</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #0000BB">$path</span><span style="color: #007700">, </span><span style="color: #0000BB">$value</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">$r</span><span style="color: #007700">)<br />  echo </span><span style="color: #DD0000">'SUCCESS'</span><span style="color: #007700">;<br />else<br />  echo </span><span style="color: #DD0000">'ERR'</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">SUCCESS</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-zookeeper.set-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="zookeeper.create.php" class="methodname" rel="rdfs-seeAlso">Zookeeper::create()</a> - Create a node synchronously</span></li>
   <li><span class="methodname"><a href="zookeeper.get.php" class="methodname" rel="rdfs-seeAlso">Zookeeper::get()</a> - Gets the data associated with a node synchronously</span></li>
   <li><span class="classname"><a href="class.zookeeperexception.php" class="classname">ZookeeperException</a></span></li>
  </ul>
 </div>


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