3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Singleton { # Holds Parent Instance private static $_instance; # Holds Reference To zVal protected $_args; # Create The Instance protected function __construct() {} # Static Call To Get Instance public static function getInstance() { return self::$_instance ?? (self::$_instance = new self()); } # Bind zVal Of Passed Reference To Index protected function _bindParam(&$val) { $this->_arg = &$val; return $this; } } abstract class Model { abstract public function save(); # Set your DB up here } class MyModel extends Model { use \Singleton { _bindParam as public bindParam; } public function save() { print_r($this->_arg); } } MyModel::getInstance()->bindParam($row); foreach([['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I']] as $key => $row) { $row[0] = 'Changed'; MyModel::getInstance()->save(); }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property MyModel::$_arg is deprecated in /in/ePbei on line 21 Array ( [0] => Changed [1] => B [2] => C ) Array ( [0] => Changed [1] => E [2] => F ) Array ( [0] => Changed [1] => H [2] => I )

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:
136.14 ms | 406 KiB | 5 Q