PHP While

Discussion in 'OT Technology' started by makavelimx, Aug 2, 2005.

  1. makavelimx

    makavelimx Guest

    http://us2.php.net/while

    I'm trying to do self studying on this but could somoene explain in english

    what the while loop is for? and/or give some examples to help futher the explaination?
     
  2. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,924
    Likes Received:
    11
    Location:
    Los Angeles
    While a statement is true, continue the loop. Otherwise, exit the loop. It's pretty straight forward.

    Here's a php example:
    PHP:
    $user "makavelimx";
    while (
    $user == "n00b") {
         echo 
    "This is a never endling loop";
    }
     
  3. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    here is an easier example using a counter
    PHP:
    $counter 0;
    while(
    $counter<=10){
     echo 
    $counter;
     
    $counter++;
    }
    if the counter isnt increased, you will get an endless loop. it is a conditional loop
     

Share This Page