What best practices should be followed when initializing and incrementing variables within loops in PHP?

When initializing and incrementing variables within loops in PHP, it is important to follow best practices to ensure code readability and maintainability. It is recommended to initialize variables outside the loop to avoid reinitializing them on each iteration. Additionally, incrementing variables should be done within the loop body to clearly indicate where the value is being updated.

// Initializing variables outside the loop
$count = 0;

// Loop example
for ($i = 0; $i < 10; $i++) {
    // Incrementing variable within the loop
    $count++;
    echo $count . "\n";
}