#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    4
    Rep Power
    0

    Need solution and explanation


    $x=1;
    while($x++<=5);
    echo $x;

    what will be the result and give me explanation pl
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,960
    Rep Power
    9397
    Try describing what the code is doing without using code. With regular words. Remember that $x++ means "use the current value of $x and then increment it behind the scenes".
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by requinix
    Try describing what the code is doing without using code. With regular words. Remember that $x++ means "use the current value of $x and then increment it behind the scenes".
    Hi,

    i know that ,but i am getting the result of 6 when i executed manually without having the system.
    using the system the value is 7

    give me the solution step by step
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,960
    Rep Power
    9397
    The while loop will keep executing the condition until it fails. So the last iteration will be when $x++ > 5.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by requinix
    The while loop will keep executing the condition until it fails. So the last iteration will be when $x++ > 5.
    thank u
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by requinix
    The while loop will keep executing the condition until it fails. So the last iteration will be when $x++ > 5.
    add me in gtalk

    gopichandmenta

IMN logo majestic logo threadwatch logo seochat tools logo