Weak ReferencesTable of Contents
The WeakRef classIntroductionThe WeakRef class provides a gateway to objects without preventing the garbage collector from freeing those objects. It also provides a way to turn a weak reference into a strong one. Class synopsisWeakRef
class WeakRef
{
/* Methods */
public Weakref::__construct
( object
$object
)
public bool Weakref::acquire
( void
)
public object Weakref::get
( void
)
public bool Weakref::release
( void
)
public bool Weakref::valid
( void
)
}Examples
Example #1 WeakRef usage example
<?php The above example will output: Object still exists! object(MyClass)#1 (0) { } Destroying object! Object is dead! The WeakMap classIntroduction
Class synopsisWeakMap
class WeakMap
implements
Countable
,
ArrayAccess
,
Iterator
{
/* Methods */
public __construct
( void
)
public int count
( void
)
public mixed current
( void
)
public object key
( void
)
public void next
( void
)
public bool offsetExists
( object
$object
)
public mixed offsetGet
( object
$object
)
public void offsetSet
( object
$object
, mixed $value
)
public void offsetUnset
( object
$object
)
public void rewind
( void
)
public bool valid
( void
)
}Examples
Example #1 Weakmap usage example
<?php The above example will output: int(1) Unsetting.. Dead! Done int(0) |