Php XOR mantığı ve koşul sorgulama (turkish tutorial)

in #utopian-io7 years ago (edited)

English
Hello to everyone my name is eresbos,

  • What is XOR logic and condition inquiry?
  • How to use XOR logic and condition inquiry?

Türkçe

Merhaba arkadaşlar ben eresbos, bugün sizlere php üzerinde örneklendirerek 'OR', 'AND' ve 'XOR' koşullarının nasıl çalıştığını ve ne işe yaradıklarını anlatacağım.

  • XOR koşulu nedir?
  • XOR koşulu nasıl kullanılır?

AND = iki koşulda doğru ise,
OR = koşullardan biri veya ikisi doğru ise,
XOR = 'AND' veya 'OR' koşulundan birisi doğru ise çalışır.

1- İki adet değişken oluşturuyoruz '$a=5 ve $b=6' ardından koşulumuzu yazdık 'if ($a==5 OR $b==6)'.Ekrana bastıracağımız sonuç satırlarını doğru ise 'echo "doğru"' else yanlış ise (else) 'echo "yanlış" şeklinde yazıyoruz.

    <?php


    //XOR


    $a=5;
    $b=6;

 if ($a==5 OR $b==6) {

    echo "doğru";
} else {

echo "yanlış";

}

    ?>

1.png

2.png

2- Burada değişkenlerimizi '$a=5 ve $b=8' şeklinde değiştirirsek '$a=5' değişkeni doğru olduğu için ekrana tekrar doğru sonucunu basacaktır.

<?php


//XOR


$a=5;
$b=6;

($a==5 Of $b==8) {

 echo "doğru";

} else {

echo "yanlış";

}


?>

3.png

4.png

3- Eğer 'OR' koşulunu 'AND' koşulu ile değiştirirsek ekrana yanlış olarak sonucu basacaktır.Nedeni ise, a değişkeni 5 e eşit ve b değişkeni 8 e eşit olmalıdır yani iki koşulunda doğru olması gerekiyor, ama maalesef iki değişkenimiz aynı anda doğru olmuyor.

<?php


//XOR


$a=5;
$b=6;

 if ($a==5 AND $b==8) { 
    echo "doğru";

} else {

    echo "yanlış";

}


    ?>

5.png

6.png

4- 'AND' koşulunu 'XOR' koşulu ile değiştirirsek ekrana doğru olarak sonucu basacaktır.Nedeni ise $a=5 yani 'OR' koşulunun doğru olmasıdır.

 <?php

    //XOR



 $a=5;
 $b=6;

 if ($a==5 XOR $b==8) {

    echo "doğru";

} else {

    echo "yanlış";
}

 
 ?>

7.png

8.png

5- Tekrar değişkenlerimizi '$a=8 ve $b=8' şeklinde değiştirip 'XOR' koşulu ile yazarsak, sonuç ekrana yanlış sonucunu basacaktır.Nedeni ise 'OR' veya 'AND' koşullarının ikisininde sonucunun yanlış olmasıdır.

<?php


//XOR


$a=5;
$b=6;

if ($a==8 XOR $b==8) {

    echo "doğru";

} else {

echo "yanlış";

}

 ?>

9.png

10.png

6- Değişkenlerimizi son olarak '$a=8 ve $b=6' şeklinde değiştirip 'XOR' koşulu ile yazarsak '$b=6' koşulu doğru olduğu için ekrana doğru sonucunu basacaktır.

    <?php


    //XOR


    $a=5;
    $b=6;

    if ($a==8 XOR $b==6) {

    echo "doğru";

    } else {

    echo "yanlış";

}

 ?>

11.png

12.png

Github proje linki : https://github.com/php/php-src



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @eresbos I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.20
TRX 0.14
JST 0.030
BTC 68221.63
ETH 3277.70
USDT 1.00
SBD 2.66