note 70853 deleted from function.func-get-args by tularis

From: Date: Fri, 15 Jul 2011 09:07:50 +0000
Subject: note 70853 deleted from function.func-get-args by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181560@lists.php.net to get a copy of this message
Note Submitter: ---- Same idea as below, but this: <?php foreach( $args as $k => $v ){ switch($k){ case 'a': $this->a= $v; break; case 'b': $this->b= $v; break; case 'c': $this->c= $v; break; } } ?> can be shortened to this (as long as all public variables have default values set in their declarations): <?php foreach( $args as $k=>$v) if(isset($this->$k)) $this->$k = $v; ?>

« previous php.notes (#181560) next »