3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $value = 42; public function property( $value = null ) { $ret = $this->value; if ( func_num_args() === 0 ) { echo "Called as getter!\n"; } else { echo "Called as setter!\n"; $this->value = $value; } return $ret; } } $foo = new Foo; echo "Calling as getter...\n"; var_dump( $foo->property() ); echo "Calling as setter...\n"; var_dump( $foo->property( 123 ) ); echo "Calling as setter, passing null...\n"; var_dump( $foo->property( null ) ); echo "Calling as getter...\n"; var_dump( $foo->property() );
Output for git.master, git.master_jit, rfc.property-hooks
Calling as getter... Called as getter! int(42) Calling as setter... Called as setter! int(42) Calling as setter, passing null... Called as setter! int(123) Calling as getter... Called as getter! NULL

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:
31.11 ms | 405 KiB | 5 Q