+ 2

Can somebody explain me a php code please?

The given code is: $x=1; While($x<10){ Echo $x; $x=$x + 3; } The result is 147. All i want to know is the steps to get to that result. Thank you

7th Aug 2018, 8:03 AM
razvan
razvan - avatar
3 Réponses
+ 6
In first iteration x value is 1 , hence while condition stands true and print 1 and increase x value by 3 means now x value is 4. Again condition stands true , it prints 4 and increase x value by 3 means now x value is 7. Again condition stands true , it prints 7 and increase x value by 3 means now x value is 10. Now 10 < 10 stands false and hence output will be 147 Hope this helps ☺️☺️.
7th Aug 2018, 8:13 AM
Meet Mehta
Meet Mehta - avatar
+ 2
right. understood now. thanks a lot :)
7th Aug 2018, 8:14 AM
razvan
razvan - avatar
+ 1
Happy that helped☺️☺️.
7th Aug 2018, 8:44 AM
Meet Mehta
Meet Mehta - avatar