3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Some file #1 */ /** * Using a class to orginize your commonly accessed variables has a few * benifits, one of which is being able to well document each variable. */ class my_vars { /** * Does this, this, and this. Is set in /path/file.ext */ public static $var1; /** * Does this, this, and this. Is set by my_vars::init() */ public static $var2; /** * Does this, this, and this. */ public static $var3 = 'baz'; /*** Methods ***/ /** * Sets up some of the variables values. Should be called at the end of this * file, or sometime later in the script. */ public static function init() { self::$var2 = 'bar'; } } my_vars::init(); /* Some (later) file #2 */ function my_func() { // do stuff my_vars::$var1 = 'foo'; // do stuff } my_func(); echo my_vars::$var1."\n"; echo my_vars::$var2."\n"; echo my_vars::$var3; ?>
Output for git.master, git.master_jit, rfc.property-hooks
foo bar baz

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