Skip to content

Instantly share code, notes, and snippets.

@yitznewton
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save yitznewton/0dfcc01973158e4cf1d8 to your computer and use it in GitHub Desktop.

Select an option

Save yitznewton/0dfcc01973158e4cf1d8 to your computer and use it in GitHub Desktop.
PHP pseudo-overload getter/setter
<?php
class Foo
{
private $bar;
public function bar($newBar = null)
{
if ($newBar !== null) {
$this->bar = $newBar;
} else {
return $this->bar;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment