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

search for in the

Weakref::get> <Weakref::acquire
[edit] Last updated: Fri, 17 May 2013

view this page in

Weakref::__construct

(PECL weakref >= 0.1.0)

Weakref::__constructConstruye una nueva referencia débil

Descripción

public Weakref::__construct() ([ object $object ] )

Construye una nueva referencia débil.

Parámetros

object

El objeto a referenciar.

Valores devueltos

No devuelve ningún valor.

Ejemplos

Ejemplo #1 Ejemplo de Weakref::__construct()

<?php
class MiClase {
    public function 
__destruct() {
        echo 
"¡Destruyendo el objeto!\n";
    }
}

$o1 = new MiClase;

$r1 = new Weakref($o1);

if (
$r1->valid()) {
    echo 
"¡El objeto aún existe!\n";
    
var_dump($r1->get());
} else {
    echo 
"¡El objeto está muerto!\n";
}

unset(
$o1);

if (
$r1->valid()) {
    echo 
"¡El objeto aún existe!\n";
    
var_dump($r1->get());
} else {
    echo 
"¡El objeto está muerto!\n";
}
?>

El resultado del ejemplo sería:

¡El objeto aún existe!
object(MiClase)#1 (0) {
}
¡Destruyendo el objeto!
¡El objeto está muerto!



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

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