Created
March 26, 2015 04:40
-
-
Save johnsonch/47d30074e3be89270d11 to your computer and use it in GitHub Desktop.
Simple PHP class example for class
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
class Car{ | |
public $make; | |
public $model; | |
public function getMake(){ | |
return $this->make; | |
} | |
public function setMake($input_make){ | |
$this->make = $input_make; | |
} | |
public function owner(){ | |
return 'CJ'; | |
} | |
} | |
$myCar = new Car; | |
$myCar->make = 'Ford'; | |
$myCar->model = 'Escape'; | |
echo $myCar->owner(); // CJ | |
echo $myCar->$make; // Ford |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment