Showing posts with label inheritance in php. Show all posts
Showing posts with label inheritance in php. Show all posts

Friday, July 31, 2015

Inheritance in PHP

As I learned programming specially PHP one of my favorite web programming language I have to admit that some of the advance concepts like object oriented programming I'm not yet equip with. One of its is the concept of inheritance this concepts is one of the most important aspect in object oriented programming not only in PHP but other programming language like Java and C#.

Inheritance teaches us how to use the attributes and methods from the parent class. It makes our programming much easier in a sense that we use existing codes in the library class file specially we are using web frameworks like codeigniter, laravel, magento and many others. I hope you will find my program useful in learning the concepts of object oriented programming in PHP using the concepts of inheritance.

If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output


Program Listing


<?php

class user_details {
public $name;
public $address;
public $age;
public  $email;
function display_user_details() {
echo "<font color='blue'>";
echo "<h2> About the User </h1>";
echo "<h4> Name                : " .$this->name. "</h4>";
echo "<h4> Address             : " .$this->email. "</h4>";
echo "<h4> Age                 : " .$this->age. "</h4>";
echo "<h4> Email Address       : " .$this->email. "</h4>";
echo "</font>";
}
}


class person extends user_details {
}

$user = new person;
$user->name='Willian Gates III';
$user->address= 'One Microsoft Way';
$user->age= 60;
$user->email= 'bill_gates@microsoft.com';
$user->display_user_details();

?>