Created
February 12, 2019 18:47
-
-
Save andonovn/75f8e96a70b852e43a855a08ac507a9f to your computer and use it in GitHub Desktop.
OOP basics
This file contains 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 | |
require 'Person.php'; | |
$pesho = new Person; | |
$pesho->setHairColor('orange'); | |
$pesho->printHairColor(); | |
$ivan = new Person; | |
$ivan->setHairColor('black'); | |
$ivan->printHairColor(); |
This file contains 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 Person | |
{ | |
protected $hairColor; | |
protected $eyeColor; | |
public function run() | |
{ | |
echo 'running'; | |
} | |
public function setHairColor($color) | |
{ | |
$this->hairColor = $color; | |
} | |
public function printHairColor() | |
{ | |
echo $this->hairColor; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment