Skip to content

Instantly share code, notes, and snippets.

@bobbravo2
Created November 16, 2016 00:22
Show Gist options
  • Save bobbravo2/e5906888141502f45cf531c5fe48965f to your computer and use it in GitHub Desktop.
Save bobbravo2/e5906888141502f45cf531c5fe48965f to your computer and use it in GitHub Desktop.
<?php
/**
* Class Car
*
* @property integer fuelType fuel value
*/
class Car {
private $data = array();
public function __construct ()
{
}
public function __get ($key)
{
return array_key_exists( $key, $this->data) ? $this->data[$key] : false;
}
public function __set ($key, $value)
{
$this->data[$key] = $value;
}
public function printData ()
{
print_r($this->data) . PHP_EOL;
}
}
$bobCar = new Car();
$bobCar->fuelType = 'Unleaded';
$bobCar->color = 'Red';
$bobCar->printData();
echo 'Got Octane #: ' . $bobCar->octane;
var_dump( $bobCar->foobar );
echo 'Done' . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment