Re: [PHP-DEV] The curious case of the comparable objects.

2018-08-11 Thread Stanislav Malyshev
Hi! > One of the contributors for the "Because, PHP" page came up with a fun > example where the result of object comparison changes upon observation > of that object. Undefined behavior is undefined :) > 1. Does this matter? (I think so, it's spooky action at a distance) No. There's no defined

[PHP-DEV] The curious case of the comparable objects.

2018-08-10 Thread Sara Golemon
One of the contributors for the "Because, PHP" page came up with a fun example where the result of object comparison changes upon observation of that object. class A { public $a; } class B extends A { public $b; } $a = new B(); $a->a = 0; $a->b = 1; $b = new B(); $b->a = 1; $b->b = 0; var_dump($a