3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $public_parent; protected $protected_parent; private $private_parent; public function whoami() { echo PHP_EOL, __METHOD__, PHP_EOL; echo 'self::class: ', self::class, PHP_EOL; echo 'static::class: ', static::class, PHP_EOL; echo 'property public_parent exists ? ', var_export(property_exists(static::class, 'public_parent'), true), PHP_EOL; echo 'property protected_parent exists ? ', var_export(property_exists(static::class, 'protected_parent'), true), PHP_EOL; echo 'property private_parent exists ? ', var_export(property_exists(static::class, 'private_parent'), true), PHP_EOL; echo 'property public_child exists ? ', var_export(property_exists(static::class, 'public_child'), true), PHP_EOL; echo 'property protected_child exists ? ', var_export(property_exists(static::class, 'protected_child'), true), PHP_EOL; echo 'property private_child exists ? ', var_export(property_exists(static::class, 'private_child'), true), PHP_EOL; echo 'property public_grandchild exists ? ', var_export(property_exists(static::class, 'public_grandchild'), true), PHP_EOL; echo 'property protected_grandchild exists ? ', var_export(property_exists(static::class, 'protected_grandchild'), true), PHP_EOL; echo 'property private_grandchild exists ? ', var_export(property_exists(static::class, 'private_grandchild'), true), PHP_EOL; } } class Foo_Child extends Foo { public $public_child; protected $protected_child; private $private_child; public function whoami() { echo PHP_EOL, __METHOD__, PHP_EOL; echo 'self::class: ', self::class, PHP_EOL; echo 'static::class: ', static::class, PHP_EOL; echo 'property public_parent exists ? ', var_export(property_exists(static::class, 'public_parent'), true), PHP_EOL; echo 'property protected_parent exists ? ', var_export(property_exists(static::class, 'protected_parent'), true), PHP_EOL; echo 'property private_parent exists ? ', var_export(property_exists(static::class, 'private_parent'), true), PHP_EOL; echo 'property public_child exists ? ', var_export(property_exists(static::class, 'public_child'), true), PHP_EOL; echo 'property protected_child exists ? ', var_export(property_exists(static::class, 'protected_child'), true), PHP_EOL; echo 'property private_child exists ? ', var_export(property_exists(static::class, 'private_child'), true), PHP_EOL; echo 'property public_grandchild exists ? ', var_export(property_exists(static::class, 'public_grandchild'), true), PHP_EOL; echo 'property protected_grandchild exists ? ', var_export(property_exists(static::class, 'protected_grandchild'), true), PHP_EOL; echo 'property private_grandchild exists ? ', var_export(property_exists(static::class, 'private_grandchild'), true), PHP_EOL; parent::whoami(); } } class Foo_GrandChild extends Foo_Child { public $public_grandchild; protected $protected_grandchild; private $private_grandchild; public function whoami() { echo PHP_EOL, __METHOD__, PHP_EOL; echo 'self::class: ', self::class, PHP_EOL; echo 'static::class: ', static::class, PHP_EOL; echo 'property public_parent exists ? ', var_export(property_exists(static::class, 'public_parent'), true), PHP_EOL; echo 'property protected_parent exists ? ', var_export(property_exists(static::class, 'protected_parent'), true), PHP_EOL; echo 'property private_parent exists ? ', var_export(property_exists(static::class, 'private_parent'), true), PHP_EOL; echo 'property public_child exists ? ', var_export(property_exists(static::class, 'public_child'), true), PHP_EOL; echo 'property protected_child exists ? ', var_export(property_exists(static::class, 'protected_child'), true), PHP_EOL; echo 'property private_child exists ? ', var_export(property_exists(static::class, 'private_child'), true), PHP_EOL; echo 'property public_grandchild exists ? ', var_export(property_exists(static::class, 'public_grandchild'), true), PHP_EOL; echo 'property protected_grandchild exists ? ', var_export(property_exists(static::class, 'protected_grandchild'), true), PHP_EOL; echo 'property private_grandchild exists ? ', var_export(property_exists(static::class, 'private_grandchild'), true), PHP_EOL; parent::whoami(); } } echo '==== GRANDCHILD OUTSIDE ====', PHP_EOL; $foo_grandchild = new Foo_GrandChild; echo 'property public_parent exists ? ', var_export(property_exists($foo_grandchild, 'public_parent'), true), PHP_EOL; echo 'property protected_parent exists ? ', var_export(property_exists($foo_grandchild, 'protected_parent'), true), PHP_EOL; echo 'property private_parent exists ? ', var_export(property_exists($foo_grandchild, 'private_parent'), true), PHP_EOL; echo 'property public_child exists ? ', var_export(property_exists($foo_grandchild, 'public_child'), true), PHP_EOL; echo 'property protected_child exists ? ', var_export(property_exists($foo_grandchild, 'protected_child'), true), PHP_EOL; echo 'property private_child exists ? ', var_export(property_exists($foo_grandchild, 'private_child'), true), PHP_EOL; echo 'property public_grandchild exists ? ', var_export(property_exists($foo_grandchild, 'public_grandchild'), true), PHP_EOL; echo 'property protected_grandchild exists ? ', var_export(property_exists($foo_grandchild, 'protected_grandchild'), true), PHP_EOL; echo 'property private_grandchild exists ? ', var_export(property_exists($foo_grandchild, 'private_grandchild'), true), PHP_EOL; echo PHP_EOL, '==== INSIDE GRANDCHILD ====', PHP_EOL; $foo_grandchild->whoami(); echo PHP_EOL, '==== CHILD OUTSIDE ====', PHP_EOL; $foo_child = new Foo_Child; echo 'property public_parent exists ? ', var_export(property_exists($foo_child, 'public_parent'), true), PHP_EOL; echo 'property protected_parent exists ? ', var_export(property_exists($foo_child, 'protected_parent'), true), PHP_EOL; echo 'property private_parent exists ? ', var_export(property_exists($foo_child, 'private_parent'), true), PHP_EOL; echo 'property public_child exists ? ', var_export(property_exists($foo_child, 'public_child'), true), PHP_EOL; echo 'property protected_child exists ? ', var_export(property_exists($foo_child, 'protected_child'), true), PHP_EOL; echo 'property private_child exists ? ', var_export(property_exists($foo_child, 'private_child'), true), PHP_EOL; echo 'property public_grandchild exists ? ', var_export(property_exists($foo_child, 'public_grandchild'), true), PHP_EOL; echo 'property protected_grandchild exists ? ', var_export(property_exists($foo_child, 'protected_grandchild'), true), PHP_EOL; echo 'property private_grandchild exists ? ', var_export(property_exists($foo_child, 'private_grandchild'), true), PHP_EOL; echo PHP_EOL, '==== INSIDE CHILD ====', PHP_EOL; $foo_child->whoami(); echo PHP_EOL, '==== PARENT OUTSIDE ====', PHP_EOL; $foo = new Foo; echo 'property public_parent exists ? ', var_export(property_exists($foo, 'public_parent'), true), PHP_EOL; echo 'property protected_parent exists ? ', var_export(property_exists($foo, 'protected_parent'), true), PHP_EOL; echo 'property private_parent exists ? ', var_export(property_exists($foo, 'private_parent'), true), PHP_EOL; echo 'property public_child exists ? ', var_export(property_exists($foo, 'public_child'), true), PHP_EOL; echo 'property protected_child exists ? ', var_export(property_exists($foo, 'protected_child'), true), PHP_EOL; echo 'property private_child exists ? ', var_export(property_exists($foo, 'private_child'), true), PHP_EOL; echo 'property public_grandchild exists ? ', var_export(property_exists($foo, 'public_grandchild'), true), PHP_EOL; echo 'property protected_grandchild exists ? ', var_export(property_exists($foo, 'protected_grandchild'), true), PHP_EOL; echo 'property private_grandchild exists ? ', var_export(property_exists($foo, 'private_grandchild'), true), PHP_EOL; echo PHP_EOL, '==== INSIDE PARENT ====', PHP_EOL; $foo->whoami();
Output for git.master, git.master_jit, rfc.literals
==== GRANDCHILD OUTSIDE ==== property public_parent exists ? true property protected_parent exists ? true property private_parent exists ? false property public_child exists ? true property protected_child exists ? true property private_child exists ? false property public_grandchild exists ? true property protected_grandchild exists ? true property private_grandchild exists ? true ==== INSIDE GRANDCHILD ==== Foo_GrandChild::whoami self::class: Foo_GrandChild static::class: Foo_GrandChild property public_parent exists ? true property protected_parent exists ? true property private_parent exists ? false property public_child exists ? true property protected_child exists ? true property private_child exists ? false property public_grandchild exists ? true property protected_grandchild exists ? true property private_grandchild exists ? true Foo_Child::whoami self::class: Foo_Child static::class: Foo_GrandChild property public_parent exists ? true property protected_parent exists ? true property private_parent exists ? false property public_child exists ? true property protected_child exists ? true property private_child exists ? false property public_grandchild exists ? true property protected_grandchild exists ? true property private_grandchild exists ? true Foo::whoami self::class: Foo static::class: Foo_GrandChild property public_parent exists ? true property protected_parent exists ? true property private_parent exists ? false property public_child exists ? true property protected_child exists ? true property private_child exists ? false property public_grandchild exists ? true property protected_grandchild exists ? true property private_grandchild exists ? true ==== CHILD OUTSIDE ==== property public_parent exists ? true property protected_parent exists ? true property private_parent exists ? false property public_child exists ? true property protected_child exists ? true property private_child exists ? true property public_grandchild exists ? false property protected_grandchild exists ? false property private_grandchild exists ? false ==== INSIDE CHILD ==== Foo_Child::whoami self::class: Foo_Child static::class: Foo_Child property public_parent exists ? true property protected_parent exists ? true property private_parent exists ? false property public_child exists ? true property protected_child exists ? true property private_child exists ? true property public_grandchild exists ? false property protected_grandchild exists ? false property private_grandchild exists ? false Foo::whoami self::class: Foo static::class: Foo_Child property public_parent exists ? true property protected_parent exists ? true property private_parent exists ? false property public_child exists ? true property protected_child exists ? true property private_child exists ? true property public_grandchild exists ? false property protected_grandchild exists ? false property private_grandchild exists ? false ==== PARENT OUTSIDE ==== property public_parent exists ? true property protected_parent exists ? true property private_parent exists ? true property public_child exists ? false property protected_child exists ? false property private_child exists ? false property public_grandchild exists ? false property protected_grandchild exists ? false property private_grandchild exists ? false ==== INSIDE PARENT ==== Foo::whoami self::class: Foo static::class: Foo property public_parent exists ? true property protected_parent exists ? true property private_parent exists ? true property public_child exists ? false property protected_child exists ? false property private_child exists ? false property public_grandchild exists ? false property protected_grandchild exists ? false property private_grandchild exists ? false

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:
12.49 ms | 420 KiB | 5 Q