3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User{ protected $activeProducts = null; protected $pdo; public function __construct(PDO $pdo = null){ $this->pdo = $pdo; } public function getProducts(){ if($this->activeProducts){ echo "getting from property (cache)\n"; return $this->activeProducts; } //$this->activeProducts = $this->pdo... a long task echo "getting from db\n"; $this->activeProducts = ['fake','products']; return $this->activeProducts; } } $user = new User(null);//for tests var_dump($user->getProducts()); var_dump($user->getProducts());
Output for git.master, git.master_jit, rfc.property-hooks
getting from db array(2) { [0]=> string(4) "fake" [1]=> string(8) "products" } getting from property (cache) array(2) { [0]=> string(4) "fake" [1]=> string(8) "products" }

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