varemenos
5/16/2013 - 12:24 AM

PHP - Basic OOP

PHP - Basic OOP

<?
  class entry{
		private $id = -1;		 // required
		private $title = "";	 // required
		private $author = -1;	 // required, author ID
		private $excerpt = "";	 // either turn title into excerpt or manually enter one
		private $date = "";		 // required

		// #TODO
			// post type interface?
			// private $type = "";

		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;
		}
	}