Skip to content

Instantly share code, notes, and snippets.

@tadeubdev
Last active August 7, 2021 12:51
Show Gist options
  • Select an option

  • Save tadeubdev/169f7a66fb846a4e40f82d739069459e to your computer and use it in GitHub Desktop.

Select an option

Save tadeubdev/169f7a66fb846a4e40f82d739069459e to your computer and use it in GitHub Desktop.
<?php
$value = 1;
// retorna false, pois as duas expressões são verdadeiras
// value é igual a 1 e value é menor que 2
if ($value === 1 xor $value < 2) {
// code
}
// retorna true, pois a primeira expressão é negativa
// e a segunda positiva
if ($value === 2 xor $value < 2) {
// code
}
// assim como o or e o and,
// você também pode utilizar o acento círcunflexo (^)
if ($value === 1 ^ $value < 2) {
// code
}
if ($value === 2 ^ $value < 2) {
// code
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment