What is the potential issue with using a single equal sign (=) in PHP for comparison instead of the double equal sign (==)?
Using a single equal sign (=) in PHP is an assignment operator, meaning it assigns a value to a variable. When used for comparison instead of the double equal sign (==), it may not produce the expected results. To compare values in PHP, you should use the double equal sign (==) for loose comparison or the triple equal sign (===) for strict comparison.
// Incorrect comparison using single equal sign
$var = 5;
if($var = 5) {
echo "This will always be true";
}
// Correct comparison using double equal sign
$var = 5;
if($var == 5) {
echo "This will be true";
}