Jump to content

What?: A While Loop That Checks if a Function is True Calls That Function?


davidshq

Recommended Posts

Hi Folks,

I'm looking at a snippet of PHP code that looks like this:

while ($this->update_table_structure())
{
    $this->update_table_structure();
}

I'm confused as to what this achieves? It sounds to me like it is saying:

while we are updating the table structure keep on updating the table structure?

Link to comment
Share on other sites

Yeah, that looks pretty stupid.  Seems like you could accomplish the same thing with this:

while ($this->update_table_structure());

You don't need a body of the loop at all.  Also a question is why "update table structure" needs to be called multiple times sequentially instead of just once.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...