(PECL weakref >= 0.2.0)
public __construct ( )
public count ( ) : int
public current ( ) : mixed
public key ( ) : object
public next ( ) : void
public offsetExists ( object $object ) : bool
public offsetGet ( object $object ) : mixed
public offsetSet ( object $object , mixed $value ) : void
public offsetUnset ( object $object ) : void
public rewind ( ) : void
public valid ( ) : bool}
Example #1 Weakmap usage example
<?php $wm = new WeakMap(); $o = new StdClass; class A { public function __destruct() { echo "Dead!\n"; } } $wm[$o] = new A; var_dump(count($wm)); echo "Unsetting..\n"; unset($o); echo "Done\n"; var_dump(count($wm));
The above example will output:
int(1) Unsetting.. Dead! Done int(0)
© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/class.weakmap.php