What are some common beginner mistakes when working with PHP loops?

One common beginner mistake when working with PHP loops is forgetting to increment the loop counter variable within the loop, causing an infinite loop. To solve this issue, make sure to increment the counter variable inside the loop to ensure that the loop will eventually terminate.

// Incorrect loop without incrementing the counter variable
$counter = 0;
while ($counter < 5) {
    echo $counter;
    // missing $counter++;
}

// Corrected loop with counter variable increment
$counter = 0;
while ($counter < 5) {
    echo $counter;
    $counter++;
}