PHP 8.5.0 RC 2 available for testing

variant_xor

(PHP 5, PHP 7, PHP 8)

variant_xorEjecuta una exclusión lógica sobre dos variantes

Descripción

variant_xor(mixed $left, mixed $right): variant

Ejecuta una exclusión lógica sobre dos variantes.

Parámetros

left

El operando de la izquierda.

right

El operando de la derecha.

Nota:

Al igual que para todas las funciones aritméticas, los parámetros para esta función pueden ser ya sea un tipo nativo de PHP (entero, string, float, bool o null), o una instancia de la clase COM, VARIANT o DOTNET. Los tipos nativos de PHP serán convertidos a VARIANT utilizando las mismas reglas que las encontradas en el constructor de la clase variant. Los objetos COM y DOTNET tendrán el valor de su propiedad por defecto recuperado y utilizado como valor VARIANT.

Las funciones aritméticas VARIANT están interfazadas con las funciones equivalentes de la biblioteca COM; para más información sobre estas funciones, consúltese la biblioteca MSDN. Las funciones PHP tienen nombres ligeramente diferentes: por ejemplo, variant_add(), en PHP, corresponde a VarAdd() en la documentación MSDN.

Valores devueltos

Reglas XOR para los Variant
Si left es Si right es entonces el resultado es
truetruefalse
truefalsetrue
falsetruetrue
falsefalsefalse
nullnullnull

Errores/Excepciones

Lanza una com_exception en caso de fallo.

Ver también

  • variant_or() - Realiza una disyunción lógica sobre dos variantes
  • variant_and() - Realiza un AND entre dos variantes y devuelve el resultado

add a note

User Contributed Notes 3 notes

up
1
tinelbarb at yahoo dot com
15 years ago
I've been using a lot the VARIANT_XOR function (all the VARIANT functions ar cool) and I was faceing the problem that some custom copilation of PHP, especially LAMP packs, doesn't have the VARANT functions included, so the scripts halts.I had to find an alternative for those who doesn't have an implamentation of VARIANT_XOR.I'd love if somebody improve my "A_XOR_B" function by changing the name in "VARIANT_XOR" and to run the original VARIANT_XOR function (being optimized) if it is already in the PHP compilation, else run the custom XOR code.<?phpfunction a_xor_b($a=0, $b=0) {    return ( ($a!=$b) && ($a||$b) ) ? TRUE : FALSE ;}?>If using this function, make sure you use the same type for arguments ;-)Here is a sample code using it:<?phpif ( a_xor_b(strlen($column1)>0,strlen($column2)>0) ) {  $add_and='';}if ( !a_xor_b(strlen($column1)>0,strlen($column2)>0 ) && strlen($column1)>0 ) {  $add_and=' and ';}$some_sql_filter=$query_str.' having '.$column1.$add_and.$column2;?>The use of VARIANT_XOR was identical.@PHP TEAM: the VARIANT set is so great :-)
up
-1
tinelbarb at yahoo dot com
15 years ago
I've been using a lot the VARIANT_XOR function (all the VARIANT functions ar cool) and I was faceing the problem that some custom copilation of PHP, especially LAMP packs, doesn't have the VARANT functions included, so the scripts halts.I had to find an alternative for those who doesn't have an implamentation of VARIANT_XOR.I'd love if somebody improve my "A_XOR_B" function by changing the name in "VARIANT_XOR" and to run the original VARIANT_XOR function (being optimized) if it is already in the PHP compilation, else run the custom XOR code.<?phpfunction a_xor_b($a=0, $b=0) {    return ( ($a!=$b) && ($a||$b) ) ? TRUE : FALSE ;}?>If using this function, make sure you use the same type for arguments ;-)Here is a sample code using it:<?phpif ( a_xor_b(strlen($column1)>0,strlen($column2)>0) ) {  $add_and='';}if ( !a_xor_b(strlen($column1)>0,strlen($column2)>0 ) && strlen($column1)>0 ) {  $add_and=' and ';}$some_sql_filter=$query_str.' having '.$column1.$add_and.$column2;?>The use of VARIANT_XOR was identical.@PHP TEAM: the VARIANT set is so great :-)
up
-1
tinelbarb at yahoo dot com dot RE-MO-VE dot ME
15 years ago
I've been using a lot the VARIANT_XOR function (all the VARIANT functions ar cool) and I was faceing the problem that some custom copilation of PHP, especially LAMP packs, doesn't have the VARANT functions included, so the scripts halts.I had to find an alternative for those who doesn't have an implamentation of VARIANT_XOR.I'd love if somebody improve my "A_XOR_B" function by changing the name in "VARIANT_XOR" and to run the original VARIANT_XOR function (being optimized) if it is already in the PHP compilation, else run the custom XOR code.<?phpfunction a_xor_b($a=0, $b=0) {    return ( ($a!=$b) && ($a||$b) ) ? TRUE : FALSE ;}?>If using this function, make sure you use the same type for arguments ;-)Here is a sample code using it:<?phpif ( a_xor_b(strlen($column1)>0,strlen($column2)>0) ) {  $add_and='';}if ( !a_xor_b(strlen($column1)>0,strlen($column2)>0 ) && strlen($column1)>0 ) {  $add_and=' and ';}$some_sql_filter=$query_str.' having '.$column1.$add_and.$column2;?>The use of VARIANT_XOR was identical.@PHP TEAM: the VARIANT set is so great :-)
To Top