3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeClass { private $myData = [ 'test1' => 'a value!', 'test2' => null, ]; public function __get($name) { if (!array_key_exists($name, $this->myData)) { echo "oops, $name does not exist"; return null; } return $this->myData[$name]; } public function __isset($name) { return isset($this->myData[$name]); } } $s = new SomeClass; // this is fine, we try reading stuff and in last case, it's "not possible" echo "test1 is $s->test1"; echo "test2 is $s->test2"; echo "testX is $s->testX"; // let's check if our properties exist echo 'test1 ' . (isset($s->test1) ? 'is set' : 'is not set') . PHP_EOL; echo 'test2 ' . (isset($s->test2) ? 'is set' : 'is not set') . ' (but that\'s ok)' . PHP_EOL; echo 'testX ' . (isset($s->testX) ? 'is set' : 'is not set') . ' (but that\'s also ok)' . PHP_EOL; echo 'test2 ' . (property_exists($s, 'test2') ? 'exists' : 'is not there') . ' (yeah, strictly speaking)' . PHP_EOL; echo 'testX ' . (property_exists($s, 'testX') ? 'exists' : 'is not there') . ' (ok... so how do I know it\'s really not there?)' . PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
test1 is a value!test2 is oops, testX does not existtestX is test1 is set test2 is not set (but that's ok) testX is not set (but that's also ok) test2 is not there (yeah, strictly speaking) testX is not there (ok... so how do I know it's really not there?)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.16 ms | 2015 KiB | 4 Q