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();
based on hTpHT
Output for 8.0.0 - 8.0.3
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.26, 7.4.0 - 7.4.16
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 :