3v4l.org

run code in 300+ PHP versions simultaneously
<?php //normal function declaration function greeting(){ return "Hellow Developers!"; } echo greeting(); echo "\n"; //function argument and parameter function addition($a,$b){ return $a+$b; } echo addition(10,20); echo "\n"; //default function argument function defaultParam($a,$b=30){ return $a+$b; } echo defaultParam(10); echo "\n"; echo defaultParam(10,25); echo "\n"; //variable scope within function $global = "I am a global variable"; function variableScope(){ echo $local = "I am a local variable"; echo "\n"; global $global ; echo $global; echo "\n"; echo $GLOBALS['global']; echo "\n"; } variableScope(); //anonymous function $anonymousFunction = function($a){ return $a*$a; }; echo $anonymousFunction(10); echo "\n"; //arrow function $arraowFunc = fn($a,$b)=>($a+$b); echo $arraowFunc(20,30); echo "\n"; //callback function function myFunc($callback){ return $callback("World"); } $result = myFunc(function($xyz){ return "Hellow, $xyz"; }); echo $result; ?>
Output for git.master_jit, git.master
Hellow Developers! 30 40 35 I am a local variable I am a global variable I am a global variable 100 50 Hellow, World

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:
26.91 ms | 405 KiB | 5 Q