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 evloop creates an instance of evembed watcher associated with the current evloop objectphp evloop creates evtimer watcher object associated with the current event loop instancephp ibm db2 函数 returns an object with properties that describe the db2 database serverphp maxdb 函数 returns the current row of a result set as an objectphp semaphore 函数 returns information from the message queue data structurephp gmagick returns the size associated with the gmagick objectphp hyperwave api 函数 returns source of a destination objectphp imagick returns the size associated with the imagick objectphp intlcalendar get the locale associated with the objectphp sdo das relational 函数 returns the special root object in an otherwise empty data graph. used when creating a data graph from scratchphp sdo 函数 get the property which defines the containment relationship to the data objectphp solrclient returns the debug data for the last connection attemptphp splobjectstorage returns the data associated with the current iterator entryphp splobjectstorage returns the data associated with an objectphp splobjectstorage associates data to an object in the storagephp splobjectstorage removes an object from the storagephp splobjectstorage sets the data associated with the current iterator entryphp tidy returns a tidynode object starting from the html tag of the tidy parse treephp weakref returns the object pointed to by the weak referencephp xmlreader returns a copy of the current node as a dom object
关注编程学问公众号