CKTIS / PHP
Disgiunzione esclusiva (xor)
La disgiunzione esclusiva restituisce true quando un solo operando è vero.
Versione: PHP 8.4; repository runtime, production runtime not attested
Sintassi
($first xor $second)La disgiunzione esclusiva restituisce true quando un solo operando è vero. Due alternative vere danno false. PHP valuta entrambi i lati, che possono entrambi avere effetti collaterali. Usa le parentesi per memorizzare il risultato perché l’assegnazione ha priorità.
($first xor $second)
[true,false,false]
Esempi
<?php
$single = (true xor false);
$both = (true xor true);
$none = (false xor false);
echo json_encode([$single,$both,$none]);
Risultato
[true,false,false]