In PHP, what are the differences between the assignment operator "=" and the comparison operator "==" when used in loop conditions?

When used in loop conditions, the assignment operator "=" is used to assign a value to a variable, while the comparison operator "==" is used to compare two values for equality. Using the assignment operator "=" in a loop condition will always evaluate to true because it assigns a value to the variable each time the loop iterates. To compare values in loop conditions, you should use the comparison operator "==".

// Incorrect usage of assignment operator "=" in loop condition
for ($i = 0; $i = 10; $i++) {
    echo $i . " ";
}

// Correct usage of comparison operator "==" in loop condition
for ($i = 0; $i == 10; $i++) {
    echo $i . " ";
}