PHP 定义 Class 属性时,赋值NULL与不赋值有什么区别呢?
比如:
代码1:
class Base
{
protected $_db = NULL;
function __construct()
{
}
}
代码2:
class Base
{
protected $_db;
function __construct()
{
}
}
以上代码有什么区别呢?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
声明变量赋初值是个好习惯
没区别
http://php.net/manual/zh/language.types.null.php