Php overloading | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Php overloading

?php function add($a,$b) { $sum=$a+$b; return $sum; } function add($a,$b,$c) { $sum=$a+$b+$c; return $sum; } echo"sum of 2no".add(1020,20); echo "sum of 3 no".add(10,20,30); ?>

18th Jul 2019, 6:23 AM
Puja Agrawal
Puja Agrawal - avatar
2 Answers
0
First add < before ?php, in functions just write return $a + $b...(this is an advice) and you cannot have 2 same names of functions -> that's the actuall error
18th Jul 2019, 6:53 AM
Dejan Francuz🥇
Dejan Francuz🥇 - avatar
0
Overloading means same name
18th Jul 2019, 6:55 AM
Puja Agrawal
Puja Agrawal - avatar