PHP 5.6.40 Released

The WeakMap class

(PECL weakref >= 0.2.0)

Introducere

Sinopsisul clasei

WeakMap implements Countable , ArrayAccess , Iterator {
/* Metode */
public __construct ( void )
public count ( void ) : int
public current ( void ) : mixed
public key ( void ) : object
public next ( void ) : 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 ) : void
public valid ( void ) : bool
}

Exemple

Example #1 Weakmap usage example

<?php
$wm 
= new WeakMap();

$o = new StdClass;

class 
{
    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));

Exemplul de mai sus va afișa:

int(1)
Unsetting..
Dead!
Done
int(0)

Cuprins

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top