Oh, I see. So the function is like a black box that just does its thing and doesn't give me back the new value. Time to brush up on my PHP function basics!
I got this one! The output is 1 because the increment() function only modifies the local copy of $val, not the original variable. The echo statement outside the function still prints the original value of 1.
Haha, this is a classic gotcha question! I remember seeing something similar in my last exam. The key is that the function doesn't return the incremented value, it just modifies the original variable. So the output will be 1.
The output will be 2. The increment operator (++) increments the value of $val by 1, so after calling the increment() function, the value of $val should be 2.
Sabina
29 days agoDaren
16 days agoTommy
1 months agoJudy
1 months agoSimona
4 days agoJoanna
8 days agoBritt
22 days agoSimona
28 days agoAshley
2 months agoYesenia
2 months agoColby
2 months agoDusti
36 minutes agoNiesha
2 days agoShawna
14 days agoDorothy
15 days agoTwana
17 days agoAshley
2 months agoLinette
2 months agoGeorgeanna
2 months agoWeldon
1 months agoRachael
1 months agoMary
1 months agoDylan
2 months agoLura
2 months agoLinette
3 months ago