Php __构造($foo=NULL)不工作

Php __构造($foo=NULL)不工作,php,construct,Php,Construct,我有个奇怪的问题。这只是类的构造函数方法,不值得显示其他代码,无论如何,请看以下代码: Class xy { public $x = 10; public $y = 10; public function __construct($x = NULL, $y = NULL) { if(isset($x) || isset($y)){ $this->x = $x; // assign center coords

我有个奇怪的问题。这只是类的构造函数方法,不值得显示其他代码,无论如何,请看以下代码:

Class xy {
    public $x = 10;
    public $y = 10; 

    public function __construct($x = NULL, $y = NULL) {
        if(isset($x) || isset($y)){
            $this->x = $x;      // assign center coords
            $this->y = $y;      // assign center coords
        }
        $this->area = $this->area();
        echo $this->x . " " . $this->y . " " . $this->area;
    }

}
从现在起,我认为这个代码应该在没有if(isset($x)| | isset($y)){的情况下回显$this->x和$this->y,如果它没有通过这个代码生成对象:
$newObj=newxy;
但是它没有。它只有当这行看起来像这样时才有效


我需要帮助和澄清:)

我已经多年没有使用php了,但我认为它看起来应该是$newObj=newxy();

isset()
更改为
!is_null()
help?
$x===NULL | |$this->x=$x;
第二个参数相同。仅当不是默认值时才设置。每个参数都需要这样做。@Passerby,
isset
在逻辑上等同于
!is _NULL
(所有输入的返回值都相同)重点是,我认为它应该在没有第6行和第9行代码的情况下工作,不是吗?
change $newObj = xy(10,10); to $newObj = new xy(10,10);