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 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 I think this is what you're after: $x = 1; echo $x++; // 1 $x = 1; echo ++$x; // 2 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 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. 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 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 Link to comment https://forums.phpfreaks.com/topic/281228-need-solution-in-php/#findComment-1445411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.