Monday, May 6

Tag: refactoring

Mending a PHP do…while(false)
Mending Code

Mending a PHP do…while(false)

Today's moment in code mending madness is brought to you by the "do...while loop" . Normally a "do .. while loop" is just that -- a loop. The do statement is executed while the while statement is false. This code starts off with the while statement being false meaning the code is only executed once. So what is even the point? My inner child is rethinking her life choices Working on legacy code is full of those WTF moments where you are staring at something and can't at first glance (or fifth or twentieth) understand what is going on. Here is a cleaned out version of the issue: $condition = ''; do{ if($condition == 'a'){ echo "this is the a thing<br>"; continue; // that is a little odd } if($condition == 'b'){ echo "this is the b thing <br>"; c...