Created
November 16, 2016 00:22
-
-
Save bobbravo2/e5906888141502f45cf531c5fe48965f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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