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
2 months agoStefan
5 days agoMeaghan
6 days agoJani
7 days agoDaren
2 months agoTommy
2 months agoJudy
2 months agoJoanna
1 months agoSimona
1 months agoJoanna
1 months agoBritt
2 months agoSimona
2 months agoAshley
3 months agoYesenia
3 months agoColby
3 months agoRaymon
25 days agoNana
26 days agoRuthann
27 days agoDusti
1 months agoNiesha
1 months agoShawna
1 months agoDorothy
2 months agoTwana
2 months agoAshley
3 months agoLinette
3 months agoGeorgeanna
3 months agoWeldon
2 months agoRachael
2 months agoMary
2 months agoDylan
3 months agoLura
3 months agoLinette
4 months ago