Goldenweb.it homepage

ANNUNCI | DIRECTORY | FONTS | ICONE | NEWSGROUPS | TOP25 | WALLPAPERS

English version  

Bet365 online bets
Bet365 offers the best online betting. Our advice is to subscribe now to bet365 to instantly obtain the bonus code of $100 reserved for all new customers. Bet365 is a secure online betting site, certified and licensed throughout Europe.
Bufi Store
Bufi Store è il sito di e-commerce fra i più innovativi e tecnologici del web, alla ricerca sempre dei migliori marchi con rapporti qualità prezzo fra i migliori del mercato.

GoldenWeb.it Directory "Premium" Links - Il tuo link qui...



get_object_vars

(PHP 4 , PHP 5)

get_object_vars -- Restituisce un array associativo con le proprietà dell'oggetto

Descrizione

array get_object_vars ( object oggetto)

Questa funzione restituisce un array associativo con le proprietà definite nell'oggetto passato nel parametro oggetto .

Nota: Nelle versioni di PHP precedenti la 4.2.0, le eventuali variabili dichiarate in nella classe oggetto ma non ancora valorizzate non saranno restituite nell'array. Nelle versioni successive alla 4.2.0, saranno restituite nell'array con valore NULL.

Esempio 1. Utilizzo di get_object_vars()

<?php
class Point2D {
    var
$x, $y;
    var
$etichetta;

    function
Point2D($x, $y)
    {
        
$this->x = $x;
        
$this->y = $y;
    }

    function
setetichetta($etichetta)
    {
        
$this->etichetta = $etichetta;
    }

    function
getPoint()
    {
        return array(
"x" => $this->x,
                     
"y" => $this->y,
                     
"etichetta" => $this->etichetta);
    }
}

// "$etichetta" è dichiarata ma non definita
$p1 = new Point2D(1.233, 3.445);
print_r(get_object_vars($p1));

$p1->setetichetta("point #1");
print_r(get_object_vars($p1));

?>

L'output del programma precedente sarà:

Array ( [x] => 1.233 [y] => 3.445 [label] => ) Array ( [x] => 1.233 [y] => 3.445 [label] => point #1 )

Vedere anche get_class_methods() e get_class_vars().