I need polymorphism in php.
When I run this following code I get the following error.
Fatal error: Cannot redeclare aClass::aPrint( ) in C:\Program Files
\xampp\htdocs\k 7\prCls.php on line 16
How I rectify it?
<?php
class aClass{
function aPrint($name){
echo $name;
}
function aPrint($name,$a ge){
echo $name;
echo $age;
}
}
$myClass = new aClass;
$myClass->aPrint('Kesava n');
$myClass2 = new aClass;
$myClass2->aPrint('Kesava n',24);
?>
/
*************** *************** *************** *************** *************** *************** **************/
Kesavan M
m.kesavan@hotma il.com
When I run this following code I get the following error.
Fatal error: Cannot redeclare aClass::aPrint( ) in C:\Program Files
\xampp\htdocs\k 7\prCls.php on line 16
How I rectify it?
<?php
class aClass{
function aPrint($name){
echo $name;
}
function aPrint($name,$a ge){
echo $name;
echo $age;
}
}
$myClass = new aClass;
$myClass->aPrint('Kesava n');
$myClass2 = new aClass;
$myClass2->aPrint('Kesava n',24);
?>
/
*************** *************** *************** *************** *************** *************** **************/
Kesavan M
m.kesavan@hotma il.com
Comment