Functions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 4

Functions

What output results from the following code? function func($arg) { $result = 0; for($i=0; $i<$arg; $i++) { $result = $result + $i; } return $result; } echo func(5);

30th Dec 2016, 9:48 PM
Renice Owino
Renice Owino - avatar
14 Answers
25th Oct 2018, 12:55 PM
Hatsy Rei
Hatsy Rei - avatar
+ 8
Lord Krishna too late... just gave the badge to rei.... ;) (rip)
25th Oct 2018, 2:08 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 7
10!! ^_^ (really guys?? cant you see that the question has already been answered?? why spam?)
25th Oct 2018, 12:32 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 5
10.
30th Dec 2016, 9:52 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 4
Valen.H. ~ They aren't spamming, no answer has received the best mark (yet). They are trying for best mark, worth 10xp at best 😎.
25th Oct 2018, 2:06 PM
Lord Krishna
Lord Krishna - avatar
+ 4
Mirror mirror on the wall, Who's the greatest necromancer of them all? sanaka kavitha was the greatest in this hall, But now Houcem Eddine Aouissaoui is the greatest of them all! Houcem Eddine Longest-name-ever: Check the posting date _unless_ you have something _new_ to offer. Otherwise I'm with with Valen & Rei on this one: it's just another type of spamming. Sorry L.K. but, "A rose by any other name..." Is still a darn rose! ...and can still end with you receiving a prick that evening!
25th Oct 2018, 10:42 PM
non
+ 3
Lol, i thought it was me and my hand slipped XD
25th Oct 2018, 2:10 PM
Lord Krishna
Lord Krishna - avatar
+ 2
can someone please explain why it is 10? for every time the number is smaller then 5 add + 1? and then at the end add the 5 ? which makes 10... if this is a reasonable explanation ?
26th Dec 2018, 11:32 AM
Ferran Arnoldus
Ferran Arnoldus - avatar
+ 1
10
5th Feb 2017, 5:37 PM
sanaka kavitha
sanaka kavitha - avatar
+ 1
output results from the following code? function func($arg) { $result = 0; for($i=0; $i<$arg; $i++) { $result = $result + $i; } return $result; } echo func(5); 10
14th Sep 2019, 1:06 PM
Camilo Pereira de Deus
Camilo Pereira de Deus - avatar
0
10
4th Jun 2017, 11:48 AM
Olagoke Ibrahim
Olagoke Ibrahim - avatar
0
10
6th Jun 2017, 9:52 AM
R.kishore
R.kishore - avatar
0
10
25th Oct 2018, 12:30 PM
Houcem Eddine Aouissaoui
Houcem Eddine Aouissaoui - avatar
- 1
Your post is too amazing. I have found with ease what I was looking for. Moreover, the content quality is awesome. Thanks for the nudge! https://www.dumpscafe.com/Braindumps-8006.html
11th Dec 2020, 6:47 AM
davidwilly