Coming from C++ background ;)
How can I overload PHP functions?
One function definition if there are any arguments, and another if there are no arguments? Is it
";
}
else if($arg1 != null && $arg2 != null && $arg3 != null)
{
$volume=$arg1*$arg2*$arg3;
echo "volume of a cuboid ".$volume ."
";
}
else if($arg1 != null && $arg2 != null)
{
$area=$arg1*$arg2;
echo "area of square = " .$area ."
";
}
else if($arg1 != null)
{
$volume=$arg1*$arg1*$arg1;
echo "volume of a cube = ".$volume ."
";
}
}
}
$obj=new abs();
echo "For no arguments.
";
$obj->volume();
echo "For one arguments.
";
$obj->volume(3);
echo "For two arguments.
";
$obj->volume(3,4);
echo "For three arguments.
";
$obj->volume(3,4,5);
?>