What are common issues when using for loops in PHP, as seen in the provided code snippet?
One common issue when using for loops in PHP is off-by-one errors, where the loop either runs one too many or one too few times. To avoid this, ensure that the loop condition is correctly set to "<" or "<=" depending on the desired behavior. Additionally, make sure the loop counter is initialized properly and incremented correctly within the loop.
// Incorrect for loop causing off-by-one error
for ($i = 0; $i < 5; $i++) {
echo $i;
}
// Corrected for loop
for ($i = 0; $i <= 4; $i++) {
echo $i;
}