Function means in php? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Function means in php?

I was learning lessons of php and came through the part of functions. Can anybody tell me what is the use of functions in php??? Thanks

6th Jan 2018, 10:13 AM
Jigar Patel
3 Answers
+ 1
the goal of functions is shorter code and less effort and less time 😎
6th Jan 2018, 11:08 AM
Michael Ehab Mikhail
Michael Ehab Mikhail - avatar
+ 1
A function is a block of statements that can be used repeatedly in a program. so if you want to get the sum of 2 numbers more the one time in a program For Example : You Need To get the value of num1 and num2 and get their sum : $result = $num1 + $num2; $echo($result); and instead of writing these lines of code more than one time you can use functions example: function sum($num1,$num2) { $result = $num1 + $num2; return $result; } so any time you want to use this block of code you just need to call it by name for example we want to get the sum of 2 and 3 after we define the function we just nee to write: sum(2,3); and this will do all the work for you 😃
6th Jan 2018, 11:07 AM
Michael Ehab Mikhail
Michael Ehab Mikhail - avatar
0
😊 Ƭнαиκ ʏσʋ 😊 so much for your nice explanation
6th Jan 2018, 4:10 PM
Jigar Patel