Skip to content

Instantly share code, notes, and snippets.

@andonovn
Created February 12, 2019 18:47
Show Gist options
  • Save andonovn/75f8e96a70b852e43a855a08ac507a9f to your computer and use it in GitHub Desktop.
Save andonovn/75f8e96a70b852e43a855a08ac507a9f to your computer and use it in GitHub Desktop.
OOP basics
<?php
require 'Person.php';
$pesho = new Person;
$pesho->setHairColor('orange');
$pesho->printHairColor();
$ivan = new Person;
$ivan->setHairColor('black');
$ivan->printHairColor();
<?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