<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc'; $TOC = array(); $TOC_DEPRECATED = array(); $PARENTS = array(); include_once dirname(__FILE__) ."/toc/class.mongodb-bson-document.inc"; $setup = array ( 'home' => array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'mongodb-bson-document.offsetget.php', 1 => 'MongoDB\\BSON\\Document::offsetGet', 2 => 'Returns the value of a key in the document', ), 'up' => array ( 0 => 'class.mongodb-bson-document.php', 1 => 'MongoDB\\BSON\\Document', ), 'prev' => array ( 0 => 'mongodb-bson-document.offsetexists.php', 1 => 'MongoDB\\BSON\\Document::offsetExists', ), 'next' => array ( 0 => 'mongodb-bson-document.offsetset.php', 1 => 'MongoDB\\BSON\\Document::offsetSet', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/mongodb/bson/document/offsetget.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?> <div id="mongodb-bson-document.offsetget" class="refentry"> <div class="refnamediv"> <h1 class="refname">MongoDB\BSON\Document::offsetGet</h1> <p class="verinfo">(mongodb >=1.17.0)</p><p class="refpurpose"><span class="refname">MongoDB\BSON\Document::offsetGet</span> — <span class="dc-title">Returns the value of a key in the document</span></p> </div> <div class="refsect1 description" id="refsect1-mongodb-bson-document.offsetget-description"> <h3 class="title">说明</h3> <div class="methodsynopsis dc-description"> <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\BSON\Document::offsetGet</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$key</code></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div> </div> <div class="refsect1 parameters" id="refsect1-mongodb-bson-document.offsetget-parameters"> <h3 class="title">参数</h3> <p class="para"> <dl> <dt><code class="parameter">key</code></dt> <dd> <p class="para"> The key to retrieve from the document. </p> </dd> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-mongodb-bson-document.offsetget-returnvalues"> <h3 class="title">返回值</h3> <p class="para"> Returns the value associated with the given key. If the key is not present in the document, an exception is thrown. </p> <blockquote class="note"><p><strong class="note">注意</strong>: <span class="simpara"> When encountering a value encoded as 64-bit integer in the BSON document, the return value of this method will be a <span class="classname"><a href="class.mongodb-bson-int64.php" class="classname">MongoDB\BSON\Int64</a></span> instance. </span> </p></blockquote> </div> <div class="refsect1 errors" id="refsect1-mongodb-bson-document.offsetget-errors"> <h3 class="title">错误/异常</h3> <ul class="simplelist"> <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> on argument parsing errors.</li> <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-runtimeexception.php" class="classname">MongoDB\Driver\Exception\RuntimeException</a></span> if the key is not present in the document.</li> </ul> </div> <div class="refsect1 seealso" id="refsect1-mongodb-bson-document.offsetget-seealso"> <h3 class="title">参见</h3> <p class="para"> <ul class="simplelist"> <li><span class="methodname"><a href="arrayaccess.offsetget.php" class="methodname" rel="rdfs-seeAlso">ArrayAccess::offsetGet()</a> - 获取一个偏移位置的值</span></li> <li><span class="methodname"><a href="mongodb-bson-document.get.php" class="methodname" rel="rdfs-seeAlso">MongoDB\BSON\Document::get()</a> - Returns the value of a key in the document</span></li> </ul> </p> </div> </div><?php manual_footer($setup); ?>