3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Simple math class class Staircase { function __construct($numberOfSteps) { $this->numberOfSteps = $numberOfSteps; } //Returns a closure function buildingNumberOfSteps() { //We can't directly use $this inside closure $thisCopy = $this; return function($storeysNumber) use ($thisCopy) { return $storeysNumber*$thisCopy->numberOfSteps; }; } function buildingNumberOfStepsIncludingBasement() { return function($storeysNumber) { return ($storeysNumber + 1)*$this->numberOfSteps; }; } } $staircase = new Staircase(25); $numberOfStepsToReachRoofTopFromGround = $staircase->buildingNumberOfSteps(); $numberOfStepsToReachRoofTopFromBasement = $staircase->buildingNumberOfStepsIncludingBasement(); echo "5.3 <= PHP < 5.4 only allows me to climb from the ground... the ".$numberOfStepsToReachRoofTopFromGround(5)." steps :( ... "; echo "but with PHP >= 5.4 I can make my way from the basement to the top, climbing the ".$numberOfStepsToReachRoofTopFromBasement(5)." steps ! :D"; ?>
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property Staircase::$numberOfSteps is deprecated in /in/1WgpU on line 7 5.3 <= PHP < 5.4 only allows me to climb from the ground... the 125 steps :( ... but with PHP >= 5.4 I can make my way from the basement to the top, climbing the 150 steps ! :D

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:
43.41 ms | 402 KiB | 8 Q