3v4l.org

run code in 300+ PHP versions simultaneously
<?php class mother { function setStatic( $prop, $val ) { // After this, self:: refers to mother, yet next $class refers to... // $class = get_class( $this ); eval( "$class::\$$prop = \$$val;" ); } } class child extends mother { protected static $sProp; function writer( $value ) { parent::setStatic( 'sProp', $value ); } function reader() { return self::$sProp; } } $c = new child(); $c->writer( 3 ); echo $c->reader(); // 3
Output for git.master, git.master_jit, rfc.property-hooks
Parse error: syntax error, unexpected integer "3", expecting variable or "{" or "$" in /in/BiJL6(8) : eval()'d code on line 1
Process exited with code 255.

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:
46.26 ms | 401 KiB | 8 Q