Skip to content

Doctor Class

Doctor.php - OOP in PHP (Demonstration): Complete Code Listing

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
    class Doctor
    {
        protected $name;

        // METHODS
        //////////
        public function getName()
        {
            return $this->name;
        }

        public function setName($name)
        {
            $this->name = $name;
        }

        public function drawBlood()
        {
            echo "Doctor $this->name is drawing blood.<br/>";
        }
    }