I have strange problem. This is just constructor method of class, not worth to show other code, anyway, look at this code:
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;
}
}
Since now, I thought that this code should echo $this->x and $this->y WITHOUT if(isset($x) || isset($y)){
, if its not passed in on object making with this code: $newObj = new xy;
But it doesn't. It works only if this line looks like this $newObj = new xy(10,10)
;
I need help and clarification :)
I haven`t use php for years, but I think it should looks like $newObj = new xy();