I have been doing this (see below) for sometime and wanted to know if this would be considered best practice for a PHP setter/getter function?
This allows me to set multiple settings using
and get a value with
I look forward to your comments...
DMyers
PHP Code:
public function plugin_prefix($prefix=null) {
/* return value if no value sent in */
if ($prefix === null) {
return $this->plugin_prefix;
}
/* set file extension */
$this->plugin_prefix = $prefix;
/* chain-able */
return $this;
}
This allows me to set multiple settings using
PHP Code:
$this->my_object->plugin_prefix('foo')->extension('bar')->something_else('foobar');
and get a value with
PHP Code:
$plugin = $this->my_object->plugin_prefix();
I look forward to your comments...
DMyers