Scusate, ma non ho mai usato una sintassi simile,
potreste farmi un esempio di come vengono istanziati gli oggetti e come viene verificata la presenza di un id con queste classi?
Codice PHP:class GG {
var $id, $nome, $ruolo, $available;
// constructor
function GG( $id, $nome, $ruolo, $available ) {
$this->id = (int)$id;
$this->nome = $nome;
$this->ruolo = $ruolo;
$this->available = (bool)$available;
}
}
class GGManager {
static $GGs = array();
static function getGG( $id, $nome, $ruolo, $available ) {
foreach( self::$GGs as $key => $GG ) {
if( self::$GGs[$key]->id == $id ) {
return $gg;
}
}
$gg = new GG( $id, $nome, $ruolo, $available );
self::$GGs[] = $gg;
return $gg;
}
}

Rispondi quotando