<?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.exists.php', 1 => 'Zookeeper::exists', 2 => 'Checks the existence of a node in zookeeper synchronously', ), 'up' => array ( 0 => 'class.zookeeper.php', 1 => 'Zookeeper', ), 'prev' => array ( 0 => 'zookeeper.delete.php', 1 => 'Zookeeper::delete', ), 'next' => array ( 0 => 'zookeeper.get.php', 1 => 'Zookeeper::get', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/zookeeper/zookeeper/exists.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?> <div id="zookeeper.exists" class="refentry"> <div class="refnamediv"> <h1 class="refname">Zookeeper::exists</h1> <p class="verinfo">(PECL zookeeper >= 0.1.0)</p><p class="refpurpose"><span class="refname">Zookeeper::exists</span> — <span class="dc-title">Checks the existence of a node in zookeeper synchronously</span></p> </div> <div class="refsect1 description" id="refsect1-zookeeper.exists-description"> <h3 class="title">说明</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><strong>Zookeeper::exists</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$watcher_cb</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div> </div> <div class="refsect1 parameters" id="refsect1-zookeeper.exists-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">watcher_cb</code></dt> <dd> <p class="para"> if nonzero, a watch will be set at the server to notify the client if the node changes. The watch will be set even if the node does not </p> </dd> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-zookeeper.exists-returnvalues"> <h3 class="title">返回值</h3> <p class="para"> Returns the value of stat for the path if the given node exists, otherwise false. </p> </div> <div class="refsect1 errors" id="refsect1-zookeeper.exists-errors"> <h3 class="title">错误/异常</h3> <p class="para"> This method emits PHP error/warning when parameters count or types are wrong or fail to check the existence of a 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's derivatives. </p> </div> </div> <div class="refsect1 examples" id="refsect1-zookeeper.exists-examples"> <h3 class="title">示例</h3> <div class="example" id="zookeeper.exists.example.basic"> <p><strong>示例 #1 <span class="methodname"><strong>Zookeeper::exists()</strong></span> example</strong></p> <div class="example-contents"><p> Check the existence of a node. </p></div> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?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">$r </span><span style="color: #007700">= </span><span style="color: #0000BB">$zookeeper</span><span style="color: #007700">-></span><span style="color: #0000BB">exists</span><span style="color: #007700">(</span><span style="color: #0000BB">$path</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">'EXISTS'</span><span style="color: #007700">;<br />else<br /> echo </span><span style="color: #DD0000">'N/A or ERR'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>以上示例会输出:</p></div> <div class="example-contents screen"> <div class="examplescode"><pre class="examplescode">EXISTS</pre> </div> </div> </div> </div> <div class="refsect1 seealso" id="refsect1-zookeeper.exists-seealso"> <h3 class="title">参见</h3> <ul class="simplelist"> <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); ?>