downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

WeakMap::__construct> <Weakref::valid
[edit] Last updated: Fri, 26 Apr 2013

view this page in

The WeakMap class

(PECL weakref >= 0.2.0)

Introduction

Class synopsis

WeakMap implements Countable , ArrayAccess , Iterator , Traversable {
/* 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
$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));

The above example will output:

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

Table of Contents



add a note add a note User Contributed Notes WeakMap - [0 notes]
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites