gopichandmenta Posted August 16, 2013 Share Posted August 16, 2013 <?php $x=1; while($x++<=5); echo $x; ?> what will be the result and give me explanation pl Quote Link to comment https://forums.phpfreaks.com/topic/281228-need-solution-in-php/ Share on other sites More sharing options...
Ron916 Posted August 16, 2013 Share Posted August 16, 2013 (edited) I think this is what you're after: $x = 1; echo $x++; // 1 $x = 1; echo ++$x; // 2 Edited August 16, 2013 by Ron916 Quote Link to comment https://forums.phpfreaks.com/topic/281228-need-solution-in-php/#findComment-1445309 Share on other sites More sharing options...
aubenefit Posted August 16, 2013 Share Posted August 16, 2013 you can use this code: for($x=1; $x <=5; $x++) { echo $x; } The result is: 1 2 3 4 5 Quote Link to comment https://forums.phpfreaks.com/topic/281228-need-solution-in-php/#findComment-1445311 Share on other sites More sharing options...
cyberRobot Posted August 16, 2013 Share Posted August 16, 2013 <?php $x=1; while($x++<=5); echo $x; ?> what will be the result and give me explanation pl Did you run the code? That's an easy way to find out. Quote Link to comment https://forums.phpfreaks.com/topic/281228-need-solution-in-php/#findComment-1445336 Share on other sites More sharing options...
gristoi Posted August 16, 2013 Share Posted August 16, 2013 Sorry, I make it a point not to do other peoples homework Quote Link to comment https://forums.phpfreaks.com/topic/281228-need-solution-in-php/#findComment-1445407 Share on other sites More sharing options...
Barand Posted August 16, 2013 Share Posted August 16, 2013 <?php $x=1; while($x++<=5); echo $x; ?> what will be the result and give me explanation pl The while statement will loop until $x has a value of 6. Because of the post-increment it will then be incremented to 7 after the value test. The result will therefore be 7 is output Quote Link to comment https://forums.phpfreaks.com/topic/281228-need-solution-in-php/#findComment-1445411 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.