On Mon, 2007-11-19 at 06:27 -0500, Robert Cummings wrote: > On Mon, 2007-11-19 at 11:25 +0100, Kiketom wrote: > > Hi all. > > Yesterday i have looking for the overloading members > > > > Member overloading > > void __set ( string name, mixed value ) > > mixed __get ( string name ) > > > > As an example i put this code: > > > > class foo > > { > > private $ID; > > private $Name; > > private $LastName; > > > > private function __get($var) > > { > > return $var; > > } > > > > private function __set($var,$value) > > { > > $var = $value; > > } > > } > > > > > > $foo = new foo(); > > $foo->ID = 1; > > $foo->Name = "Henry"; > > $foo->LastName = "Ford", > > .... > > > > that's horrible!!! > > > > And if i want to validate that ID > 0?? > > > > i have to put this validation in the function __set for each property?? > > private function __set($var,$value) > > { > > if ($var = 'ID') > > { > > //validate that ID is > 0 > > } > > $var = $value; > > } > > > > > > Not exists a better method to manage the properties in a class? Why don't you use a switch btw? <?php switch( $var ) { case 'ID': { break; } case 'Name': { break; } default: { break; } } ?> Cheers, Rob. -- ........................................................... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ........................................................... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php