How does negation affect logical operators in PHP?
Negation in PHP can be achieved using the `!` operator. When negation is applied to logical operators like `&&` (AND) or `||` (OR), it reverses the truth value of the expression. This means that if the original expression evaluates to true, negating it will make it false, and vice versa.
// Example of using negation with logical operators in PHP
$var1 = true;
$var2 = false;
// Negating an AND expression
if (!$var1 && $var2) {
echo "This will not be executed.";
}
// Negating an OR expression
if (!$var1 || $var2) {
echo "This will be executed.";
}