SplObjectStorage::offsetGet

(PHP 5 >= 5.3.0, PHP 7)

SplObjectStorage::offsetGetReturns the data associated with an object

说明

public SplObjectStorage::offsetGet ( object $object ) : mixed

Returns the data associated with an object in the storage.

参数

object

The object to look for.

返回值

The data previously associated with the object in the storage.

错误/异常

Throws UnexpectedValueException when object could not be found.

范例

Example #1 SplObjectStorage::offsetGet() example

<?php
$s 
= new SplObjectStorage;

$o1 = new StdClass;
$o2 = new StdClass;

$s[$o1] = "hello";
$s->attach($o2);


var_dump($s->offsetGet($o1)); // Similar to $s[$o1]
var_dump($s->offsetGet($o2)); // Similar to $s[$o2]
?>

以上例程的输出类似于:

string(5) "hello"
NULL

参见

相关文章
php eventbufferevent returns underlying output buffer associated with current buffer eventphp ibm db2 函数 returns a result set listing the columns and associated metadata for a tablephp gmagick returns the size associated with the gmagick objectphp gmagickdraw returns the width of the stroke used to draw object outlinesphp imagick returns a reference to the current imagick objectphp imagick returns the number of images in the objectphp imagick returns a value associated with the specified keyphp imagick returns the size associated with the imagick objectphp mongodb bson binaryinterface returns the binaryinterface s dataphp mongodb driver monitoring commandfailedevent returns the exception associated with the failed commandphp mongodb driver writeconcern returns an object for bson serializationphp ktaglib mpeg file returns an object that provides access to the audio propertiesphp sdo das relational 函数 returns the special root object in an otherwise empty data graph. used when creating a data graph from scratchphp splobjectstorage returns the data associated with the current iterator entryphp splobjectstorage returns the index at which the iterator currently isphp splobjectstorage returns the data associated with an objectphp splobjectstorage associates data to an object in the storagephp splobjectstorage sets the data associated with the current iterator entryphp tidy returns a tidynode object starting from the head tag of the tidy parse treephp weakmap returns the value pointed to by a certain object
关注编程学问公众号