Skip to content

Instantly share code, notes, and snippets.

@nathan-isaac
Created December 19, 2013 22:10
Show Gist options
  • Save nathan-isaac/8047103 to your computer and use it in GitHub Desktop.
Save nathan-isaac/8047103 to your computer and use it in GitHub Desktop.
<?php
class MyClass {
private $firstField;
private $secondField;
public function __get($property) {
if (property_exists($this, $property)) {
return $this->$property;
}
}
public function __set($property, $value) {
if (property_exists($this, $property)) {
$this->$property = $value;
}
return $this;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment