Example of Inharitance in PHP ?

In this tutorial we’re going to learn how to use inharitance in php with example.

Inheritance is a way to create a new class that is a modified version of an existing class. The new class inherits properties and methods from the existing class and can also have its own additional properties and methods.

Example :-

<?php
	
	class employee {
		
		public $name;
		public $age;
		public $salary;
		
		function __construct($n, $a, $s,){
			
			$this->name = $n;
			$this->age = $a;
			$this->salary = $s;
		}
		
		function info(){
			echo"<h3>employee Profile</h3>";
			echo "employee name :" .$this->name."<br>";
			echo "employee age :" .$this->age."<br>";
			echo "employee salary :" .$this->salary."<br>";
		}
	}
	
	$e1 = new employee("Ram",25,2000);

	$e1->info();

?>

Output :-

Hi I am Amit Kumar Thakur Experienced as s Software Developer with a demonstrated history of working in the information technology and services industry. Skilled in HTML, CSS, Bootstrap4, PHP, Laravel-9 , REST API,FB API,Google API, Youtube Api, Bitbucket,Github,Linux and jQuery. Strong engineering professional focused in Computer/Information Technology Administration and Management. Currently my profile is to Software Developer, analyze the requirement, creating frame for web application, coding and maintenance.

Related Posts

How to Upload Big Database using Command in PhpMyAdmin ?

If you need to upload a large database to phpMyAdmin using a command-line interface, you can use the mysql command to import the database dump file directly…

Error: error:0308010C:digital envelope routines::unsupported

In this tutorial I’m going to share how to solve Error: error:0308010C:digital envelope routines::unsupported. Just copy below code and run your terminal. After run above all code…

API calls from the server require an appsecret_proof argument

In this tutorial im going to solve this issue API calls from the server require an appsecret_proof argument. 1st step go to developer facebook advance setting and…

How to print first 50 value and last 10 data in php

In this tutorial we’re going to share how to print first 50 value of data and the last value of data To print the first 50 values…

How to count Using substr_count function in PHP ?

In this tutorial we’re going to learn how to use substr_count function in php with example. 1step create below file And put below code Output:-

Allowed memory size of 536870912 bytes exhausted (tried to allocate 77824 bytes)

In this tutorial we’re going to solve this issue “Allowed memory size of 536870912 bytes exhausted (tried to allocate 77824 bytes)”. Error:- Solutions:- Go to below file…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x