将布尔值传递给函数 [英] Passing Boolean to a Function

查看:134
本文介绍了将布尔值传递给函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将一个布尔值传递给对象的构造函数时遇到了问题。

出于某种原因,如果我将false传递给构造函数,它就不会$ /
注册。如果我传递整数0,它会。 PHP 5代码如下:


---------------------

class Test {< br $>
var $ testBool;


公共函数__construct($ testBool){

print" testBool = $ testBool" ;;

}

}


$ testing = new Test(false); //这只是打印" testBool ="


$ testing = new Test(0); //这打印testBool = 0


--------------------

似乎两种方法都应该打印0或false。我错过了什么?

I''m having an issue passing a boolean to the constructor of an object.
For some reason, if I pass false into the constructor, it doesn''t
register. If I pass an integer 0, it does. PHP 5 Code below:

---------------------
class Test {
var $testBool;

public function __construct($testBool) {
print "testBool = $testBool";
}
}

$testing = new Test(false); // this just prints "testBool = "

$testing = new Test(0); // this prints "testBool = 0"

--------------------
Seems to be both methods should print 0 or false. What have I missed?

推荐答案

testBool;


public function __construct(
testBool;

public function __construct(


testBool){

print" testBool =
testBool) {
print "testBool =


testBool";

}

}

testBool";
}
}


这篇关于将布尔值传递给函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆