Thursday, December 26, 2013

أساسيات برمجة المواقع بي اتش بي - أمثلة على المشغلات المنطقية PHP Logical Operators Example

4:11 AM

Share it Please

 أمثلة على المشغلات المنطقية

في المثال التالي نستعرض المشغلات المنطقية.


<html>
<head><title>Logical Operators المشغلات المنطقية  </title><head>
<body>
<?php
    $a = 42;
    $b = 0;
    if( $a && $b ){
       echo "TEST1 : Both a and b are true<br/>";
    }else{
       echo "TEST1 : Either a or b is false<br/>";
    }
    if( $a and $b ){
       echo "TEST2 : Both a and b are true<br/>";
    }else{
       echo "TEST2 : Either a or b is false<br/>";
    }
    if( $a || $b ){
       echo "TEST3 : Either a or b is true<br/>";
    }else{
       echo "TEST3 : Both a and b are false<br/>";
    }
    if( $a or $b ){
       echo "TEST4 : Either a or b is true<br/>";
    }else{
       echo "TEST4 : Both a and b are false<br/>";
    }
    $a = 10;
    $b = 20;
    if( $a ){
       echo "TEST5 : a is true <br/>";
    }else{
       echo "TEST5 : a  is false<br/>";
    }
    if( $b ){
       echo "TEST6 : b is true <br/>";
    }else{
       echo "TEST6 : b  is false<br/>";
    }
    if( !$a ){
       echo "TEST7 : a is true <br/>";
    }else{
       echo "TEST7 : a  is false<br/>";
    }
    if( !$b ){
       echo "TEST8 : b is true <br/>";
    }else{
       echo "TEST8 : b  is false<br/>";
    }
?>
</body>
</html>


الناتج المشغلات المنطقية:-

TEST1 : Either a or b is false
TEST2 : Either a or b is false
TEST3 : Either a or b is true
TEST4 : Either a or b is true
TEST5 : a is true
TEST6 : b is true
TEST7 : a is false
TEST8 : b is false


Ahmed Ata Almahallawi
Freelancer
IT
IT Help Desk,
SEO experience,PHP,C#,ASPX
Al alami st
gaza -jabaliaGaza Strip
Palestine
ahmed.almahallawi@gmail.com
DOB: 05/10/1984
by +Ahmed Almahallawi 
29/12/2013

0 comments :

Post a Comment