3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $a; public function __construct(string $a) { $this->a = $a; } public function doStuff() { var_dump(isset($this->a), isset($a)); echo '$this->a holds the value of : ' . $this->a . PHP_EOL; echo '$a holds the value of : ' . $a . PHP_EOL; } } $aObject = new A("helloWorld"); $aObject->doStuff();
Output for 8.0.0 - 8.0.22, 8.1.0 - 8.1.9
bool(true) bool(false) $this->a holds the value of : helloWorld Warning: Undefined variable $a in /in/ovBDs on line 15 $a holds the value of :
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.30
bool(true) bool(false) $this->a holds the value of : helloWorld Notice: Undefined variable: a in /in/ovBDs on line 15 $a holds the value of :
Output for 7.3.32 - 7.3.33
bool(true) bool(false) $this->a holds the value of : helloWorld $a holds the value of :

preferences:
63.65 ms | 411 KiB | 5 Q