Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Polymorphism

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 149
    Comment on it

    Polymorphism in php

    Implementing the polymorphism principle can be done in either of two ways, i.e., either choosing abstract classes or interfaces.

     

    /* Program to demonstrate a polymorphism principle in php */

       <?php
    	class A
    	{
    	  function disp()
    	   {
    	     echo "display method of class A";
    	   }
    	 }
    	
    	class B extends A     // Class B inherits functions and methods of Class A
    	{
    	  function disp()
    	    {
    	      echo "display method of class B";
    	    }
    	}
    	
    	$obj = new B();
    	$obj ->disp();
         ?>

     

    Output:  display method of class B

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: