note 46480 added to ref.classobj

From: Date: Tue, 12 Oct 2004 22:58:15 +0000
Subject: note 46480 added to ref.classobj
Groups: php.notes 
Request: Send a blank email to php-notes+get-78453@lists.php.net to get a copy of this message
just in case you need 'a kind of' PUBLIC/PRIVATE access to class vars, here is my idea (I use this to generate editable forms and then calculate the full object and ->save() to db/fs) <? class User { // dati estratti da ogni view v_Utente_* var $titolo; var $nome; var $cognome; var $id; var $fk_anagrafica; var $login; var $pwd; var $datacreazione; var $datamodifica; var $lastlogin; var $active; function getVars(){ return array_keys(get_object_vars($this)); } function getPublic(){ $pub = array('titolo', 'nome', 'cognome', 'login', 'pwd'); $allVars = array_keys(get_object_vars($this)); for($i = 0; $i < count($allVars); $i++){ if(in_array($allVars[$i], $pub)) $pubVars[] = $allVars[$i]; } return $pubVars; } } class Utente_Studio extends User { var $sid; var $interno; var $ruolo; } ?> ---- Manual Page -- http://www.php.net/manual/en/ref.classobj.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46480 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46480&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46480&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46480&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46480&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46480&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46480&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+46480&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78453) next »