Friday, December 30, 2011

Simple function overloading in php

<?php
class hello
{
var $id;
 var $edi;
 function hello()
 {
 $this->id="1234";
 $this->edi="abc";
 }

public function display()
{
echo $this->id;
echo $this->edi;
}

}
class hello1 extends hello
{

 function display($a,$b)
{
hello::display();
echo "</br>";
echo $this->id=$a;
echo $this->edi=$b;
}

}
$obj=new hello;
$obj1=new hello1;
$obj1->display("a","b");


?>
output
1234abc
ab

No comments:

Post a Comment