CakeFest 2024: The Official CakePHP Conference

variant_xor

(PHP 5, PHP 7, PHP 8)

variant_xorİki varyant arasında mantıksal çıkarma yapar

Açıklama

variant_xor(mixed $sol, mixed $sag): variant

Mantıksal çıkarma yapar.

Bağımsız Değişkenler

sol

Sol terim.

sag

Sağ terim.

Bilginize:

Tüm varyant aritmetik işlevlerinde olduğu gibi, bu işlevin bağımsız değişkenleri de bir PHP yerel türü (int, string, floating point, bool veya null) veya COM, VARIANT veya DOTNET sınıfının bir örneği olabilir. PHP yerel türleri, VARIANT sınıfı için kurucuda bulunan kurallar kullanılarak varyantlara dönüştürülür. Öntanımlı özelliklerinin değerine sahip olacak COM ve DOTNET nesneleri variant değeri olarak alınır ve kullanılır.

Varyant aritmetik işlevleri, COM kütüphanesindeki benzer şekilde adlandırılmış işlevlerin sarmalayıcılardır; bu işlevler hakkında daha fazla bilgi için MSDN kütüphanesine bakılabilir. PHP işlevleri biraz farklı adlandırılır; örneğin PHP'deki variant_add(), MSDN belgelerinde VarAdd() işlevine karşılık gelir

Dönen Değerler

Varyant Mantıksal Çıkarma Kuralları
sol sag Sonuç
truetruefalse
truefalsetrue
falsetruetrue
falsefalsefalse
nullnullnull

Hatalar/İstisnalar

Başarısızlık durumunda bir com_exception yavrulanır.

Ayrıca Bakınız

  • variant_or() - İki varyant üzerinde mantıksal ayırma işlemi yapar
  • variant_and() - İki varyant üzerinde ikilik VE işlemi yapar

add a note

User Contributed Notes 3 notes

up
2
tinelbarb at yahoo dot com
13 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.

<?php
function 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:

<?php
if ( 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
13 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.

<?php
function 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:

<?php
if ( 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
13 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.

<?php
function 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:

<?php
if ( 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