Weak ReferencesInhaltsverzeichnis
The WeakRef classEinführungThe 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. KlassenbeschreibungWeakRef
class WeakRef
{
/* Methoden */
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
)
}Beispiele
Beispiel #1 WeakRef usage example
<?phpDas oben gezeigte Beispiel erzeugt folgende Ausgabe:
Object still exists!
object(MyClass)#1 (0) {
}
Destroying object!
Object is dead!
The WeakMap classEinführung
KlassenbeschreibungWeakMap
class WeakMap
implements
Countable
,
ArrayAccess
,
Iterator
{
/* Methoden */
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
)
}Beispiele
Beispiel #1 Weakmap usage example
<?phpDas oben gezeigte Beispiel erzeugt folgende Ausgabe: int(1) Unsetting.. Dead! Done int(0) |