Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在使用默认的非值参数声明用户函数时,有什么更好的方法,将参数定义为false或 as NULL?也就是说,什么更好,这个
false
NULL
function func ($param = false) { }
或这个
function func ($param = NULL) { }
?
这会更好:
“默认非值”参数应为 NULL,而不是false. False 是一个值。如果您打算测试参数的值或对其执行任何操作,我会选择false.
We can also use
function func ($param = "") {
}