PHP 中的真假

您所在的位置:网站首页 php中布尔类型数据只有两个值:true和false PHP 中的真假

PHP 中的真假

2024-04-21 23:45| 来源: 网络整理| 查看: 265

在 PHP 中使用 true 和 false 作为布尔逻辑值 在 PHP 中使用 var_dump() 函数确定布尔值

boolean 值在 php.ini 中称为 true 和 false。在 true 的情况下,输出是 1。

使用 false 时,它不显示任何输出。值得注意的是,浏览器总是以字符串的形式呈现这些值。

在 PHP 中使用 true 和 false 作为布尔逻辑值

布尔值是逻辑值。它们可以是真或假。

两者在 php 中都是区分大小写的,也是 php 中的简单数据类型。

$true = True; // returns 1 $false = False; // return nothing echo $true.PHP_EOL; echo $false; //using comparision operator to check boolean values if ($a == "abc") { echo "return boolean value"; //returns nothing since $a is not equal to abc thus it is a false } if (TRUE) { //because true means true echo "Your condition is executed!".PHP_EOL; } if (false) { echo "It will print nothing"; //false returns nothing } //Determine integer comparisions with boolean values echo 5

输出:

bool(false) bool(false) bool(true) bool(false) bool(false) bool(false) bool(false) bool(true) bool(true) bool(true) bool(true)


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3