首页 > 编程语言 >000009 PHP 逻辑运算符

000009 PHP 逻辑运算符

时间:2022-11-06 17:58:45浏览次数:40  
标签:xor 结果 000009 echo 运算符 && PHP

<?php
header('Content-Type: text/html; charset=utf-8');
include './assets/php/head.php';

//逻辑运算符 
/**
 * $a and $b:And(逻辑与) true;如果 $a 和 $b 都为 true。 
 * $a or $b:Or(逻辑或) true;如果 $a 或 $b 任一为 true。 
 * $a xor $b:Xor(逻辑异或) true;如果 $a 或 $b 任一为 true;但不同时是。 
 * ! $a:Not(逻辑非) true;如果 $a 不为 true。 
 * $a && $b:And(逻辑与) true;如果 $a 和 $b 都为 true。 
 * $a || $b:Or(逻辑或) true;如果 $a 或 $b 任一为 true。 
 * */

$a=true;
$b=false;

echo '$a=true; $b=false; <br>';

echo '$a and $b 结果:'; 
echo ($a and $b)?'真':'假';
echo '<br>';

echo '$a or $b 结果:'; 
echo ($a or $b)?'真':'假';;
echo '<br>';

echo '$a xor $b 结果:'; 
echo ($a xor $b)?'真':'假';;
echo '<br>';

echo '! $a 结果:'; 
echo ! $a?'真':'假';;
echo '<br>';

echo '$a && $b 结果:'; 
echo ($a && $b)?'真':'假';;
echo '<br>';

echo '$a || $b 结果:'; 
echo ($a || $b)?'真':'假';;
echo '<br>';

?>
<?php include './assets/php/foot.php'; ?>

结果:

标签:xor,结果,000009,echo,运算符,&&,PHP
From: https://www.cnblogs.com/onestopweb/p/16863201.html

相关文章

  • 000008 PHP 递增递减运算符
    <?phpheader('Content-Type:text/html;charset=utf-8');include'./assets/php/head.php';//递增/递减运算符/***递增/递减运算符例子名称效果*++$a前加$......
  • 000007 PHP 比较运算符
    <?phpheader('Content-Type:text/html;charset=utf-8');include'./assets/php/head.php';//比较运算符/***$a==$b等于true,如果类型转换后$a等于$b。*$a==......
  • 000006 PHP 赋值运算符
    <?phpheader('Content-Type:text/html;charset=utf-8');include'./assets/php/head.php';//赋值运算符/***例子等同于操作*$a+=$b等同于$a=$a+$b加法......
  • 000005 PHP 算术运算符
    <?phpheader('Content-Type:text/html;charset=utf-8');include'./assets/php/head.php';//算术运算符/***+$a:标识;根据情况将$a转化为int或float。*-$a:取反;$......
  • 1.4 算术运算符
    1.4算术运算符/*例1.4-1:算术运算符*/publicclassOperator01{publicstaticvoidmain(String[]args){inta=10;intb=20;......
  • 1.6 关系运算符
    1.6关系运算符/*例1.6-1:关系运算符*/publicclassOperator03{publicstaticvoidmain(String[]args){inta=10;intb=20;......
  • 1.5 赋值运算符
    1.5赋值运算符/*例1.5-1:赋值运算符*/publicclassOperator02{publicstaticvoidmain(String[]args){inta=10;intb=20;......
  • 1.8 位运算符
    1.8位运算符/*例1.87-1:位运算符*/publicclassOperator05{publicstaticvoidmain(String[]args){/*位的与或非运算A=00101010......
  • 1.7 逻辑运算符
    1.7逻辑运算符/*例1.7-1:逻辑运算符*/publicclassOperator04{publicstaticvoidmain(String[]args){booleana=true;booleanb=f......
  • C语言运算符优先级
    C语言的运算符包括单目运算符、双目运算符、三目运算符,优先级如下:第1优先级:各种括号,如()、[]等、成员运算符.;第2优先级:所有单目运算符,如++、–、!、~等;第3优先级:乘法运算......