Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9207981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:30:40+00:00 2026-06-18T00:30:40+00:00

I read this Manual by PHP.com about While loops . I don’t understand the

  • 0

I read this Manual by PHP.com about While loops.

I don’t understand the purpose of While loops in PHP.

It looks exactly like an if statement to me.

What is the difference between an if statement and a while loop?

How do while loops work, what do they do, and when should I use them?

For example, can’t this:

$i = 1;
while ($i <= 10) {
    echo $i++;
}

be done like this?:

$i = 1;
if ($i <= 10) {
    echo $i++;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:30:41+00:00Added an answer on June 18, 2026 at 12:30 am

    An if statement checks if an expression is true or false, and then runs the following code block only if it is true. The code inside the block is only run once…

    if (x > y)
    {
       // this will only happen once
    }
    

    A while statement is a loop. Basically, it continues to execute the code in the following block for however long the expression is true.

    while (x > y)
    {
      // this will keep happening until the condition is false.
    }
    

    When to use a while loop:

    While loops are best used when you don’t know exactly how many times you may have to loop through a condition – if you know exactly how many times you want to test a condition (e.g. 10), then you’d use a for loop instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read the manual from the php homepage It writes: // this doesn't go
Read some texts about locking in PHP. They all, mainly, direct to http://php.net/manual/en/function.flock.php .
I just read about unset variable through php manual. The php manual says unset()
I am learning php and read this example in this http://www.php.net/manual/en/language.types.boolean.php tutorial, I want
I read php.net manual about crypt() function. And here is my code: #code..... #we
I'm just about ready to cry. I have read the php.net manual page, tried
I've read the manual on PHP PDO and have seen this post: PDO PARAM_STR
To understand why I'm asking this, read this and the comments under it. Consider
I read this PHP RegEx page , but either I'm missing something, misreading something,
so according to this: http://php.net/manual/en/function.getimagesize.php If accessing the filename image is impossible, or if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.