Quick actions

cmd+k|ctrl+k

Navigation

Languages

Human Class

Snippet info

Language

Php

Visibility

public

Author

mynameisjoker

Created

2016-09-04T14:54:46Z

Updated

2016-09-04T14:54:51Z

<?php
	echo "<title>PHP</title>"; // TItle will be only "PHP"
	
	/* Writting abstract class of the Human */
	
	abstract class Human {
		
		protected $day;
		protected $month;
		
		public function __construct($day, $month) {
			$this->day = $day;
			$this->month = $month;
		}
		
		public function bornMessage() {
			echo $this->toBorn()."<br />";
		}
		
		abstract protected function toBorn();
		
		
	}
	
	/* Creating the class of Programmer (My class, how I was created hehehe) */
	
	class Programmer extends Human {
		
		
		public function __construct($day, $month) {
			parent::__construct($day, $month);			
		}
		
		protected function toBorn() {
			return "Programmer was born in the ".$this->day." of ".$this->month;
			
		}
		
	}
	
	/* Creating the class of the Student (The Bold's class, how he was created) */
	
	class Student extends Human {
		
		
		public function __construct($day, $month) {
			parent::__construct($day, $month);
		}
		
		protected function toBorn() {
			return "Student was born in the ".$this->day." of ".$this->month;
		}
		
		
	}
	
	$programmer = new Programmer("1st", "February"); // It will write "Programmer was born in the 1st of February"
	$programmer->bornMessage(); // Calling the method;
	$student = new Student("4th", "August"); // It will write "Student was born in the 4th of August"
	$student->bornMessage() // Calling the method;
?>
INFO