Accidentally using the assignment operator rather than the comparison for a condition

It’s easy to accidentally use the wrong operator when writing condition statements. After all, developers can spend several hours assigning values to variables. However, if you accidentally use the assignment operator instead of the conditional comparison, you run the risk of introducing bugs. php

<?php
if ($condition = 'value')
//do something
?>

In the above code, the developer mistakenly assigns the value “value” to the $condition variable. The condition should read like this: php

<?php
if ($condition == 'value') 
//do something
?>

To avoid this type of mistake, some developers prefer to use “yoda syntax.” Yoda syntax switches the order of the condition and value. This is what the above code would look like in yoda syntax: php

<?php
if ('value' == $condition)
//do something
?>

https://www.upwork.com/hiring/development/common-mistakes-avoid-php-programming/