Combination getter and setter

What do you think, good idea or bad idea?

<?php

class SomeClass
{
  public function __call($name, $args)
  {
    if (isset($args[0])) {
      $this->$name = $args[0];
      return;
    }

    return $this->$name;
  }
}

Thus you can do:

$user->first_name("justin");

Or:

print $user->first_name();

Kind of reminds me of that song.

1 comment

name
blog (optional)
comment

Hah, jQuery in PHP. I like it.

monthchunks

license

Justinsomnia is licensed under a Creative Commons Attribution 3.0 License.

Please see my Attribution Policy for more information.