What is the difference between = and == in PHP and how does it relate to variable assignment and comparison?
The difference between = and == in PHP is that = is used for variable assignment, while == is used for comparison. When using =, you are assigning a value to a variable. When using ==, you are comparing two values to see if they are equal. It is important to use the correct operator depending on whether you want to assign a value to a variable or compare two values.
// Variable assignment
$variable1 = 5;
// Comparison
if ($variable1 == 5) {
echo "Variable is equal to 5";
}