variant_xor

(PHP 5, PHP 7, PHP 8)

variant_xorИсключающее ИЛИ над двумя вариантами

Описание

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

Выполнение исключающего ИЛИ.

Список параметров

left

Левый операнд.

right

Правый операнд.

Замечание:

Как и в остальных арифметических функциях, которые работают с вариантами, параметры этой функции принимают как встроенные PHP-типы — целые числа, строки, числа с плавающей точкой, логические значения или null, — так и экземпляры классов COM, VARIANT или DOTNET. Встроенные типы языка PHP преобразуются в варианты по тем же правилам, которые содержит конструктор класса variant. Объекты классов COM и DOTNET получат значение их свойства по умолчанию, которое функция возьмёт и будет использовать как значение варианта.

Вариантные арифметические функции — обёртки одноимённых функций библиотеки COM; дополнительную информацию по этим функциям содержит библиотека технической документации MSDN. Названия PHP-функций немного отличаются; например, функция variant_add() в PHP соответствует функции VarAdd() в документации MSDN.

Возвращаемые значения

Правила выполнения исключающего ИЛИ
Если left Если right Тогда результат
truetruefalse
truefalsetrue
falsetruetrue
falsefalsefalse
nullnullnull

Ошибки

Выбрасывает исключение com_exception в случае возникновения ошибки.

Смотрите также

  • variant_or() - Побитовое ИЛИ над двумя вариантами
  • variant_and() - Побитовое И над двумя вариантами

Добавить

Примечания пользователей 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