3v4l.org

run code in 500+ PHP versions simultaneously
<?php class X { protected string $foo; public function __isset($name) { echo "DONT YOU SEE THAT THIS IS CALLED THE `FALSE` ISSNT BECAUSE ISSET() WORKS, ITS THE ISSET UNDER THAT LINE WORKS\n"; // return isset($this->foo); // But this doesn't call __isset. Even it is the same like this in line 18. return true; } public function test_isset() { var_dump(isset($this->foo)); // Is false always unset($this->foo); var_dump(isset($this->foo)); // This should be false, but it calls __isset(). } } $x = new X(); var_dump(isset($x->foo)); unset($x->foo); var_dump(isset($x->foo)); (new X())->test_isset();
Output for 8.2.31, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
DONT YOU SEE THAT THIS IS CALLED THE `FALSE` ISSNT BECAUSE ISSET() WORKS, ITS THE ISSET UNDER THAT LINE WORKS bool(true) Fatal error: Uncaught Error: Cannot access protected property X::$foo in /in/Rmvuk:23 Stack trace: #0 {main} thrown in /in/Rmvuk on line 23
Process exited with code 255.

preferences:
59.19 ms | 755 KiB | 4 Q