On 4/14/05, Tim Boring <tboring@xxxxxxxx> wrote: > Does anyone have suggestions/ideas about best practices for writing > set/get methods in PHP5? There are two basic ways I've seen this done, > which I've provided examples of below. Method #2 is obviously the easier > way, but that doesn't mean it may be the best way. > > I'm curious to read people's responses. I would start off with a simple base class like this: abstract class Base { public function __construct() { } public function __destruct() { } public function __toString() { return '<pre>' . print_r( $this, TRUE ) . '</pre>'; } public function __get( $key ) { return isset( $this->$key ) ? $this->$key : NULL; } public function __set( $key, $value ) { $this->$key = $value; } } -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php