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 "PHP >= 5.4 allows me to climb the ".$numberOfStepsToReachRoofTopFromBasement(5)." steps to reach my rooftop from the basement while "; echo "5.3 <= PHP < 5.4 only allows me to climb from the ground... the ".$numberOfStepsToReachRoofTopFromGround(5)." steps :("; ?>
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property Staircase::$numberOfSteps is deprecated in /in/JShq9 on line 7 PHP >= 5.4 allows me to climb the 150 steps to reach my rooftop from the basement while 5.3 <= PHP < 5.4 only allows me to climb from the ground... the 125 steps :(

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