3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait ClosureInATrait { public static function getClosureInTrait() { return function () { return __CLASS__; }; } } class ClassConstantTest { use ClosureInATrait; public static function getClosureInClass() { return function () { return __CLASS__; }; } } class MyClass {} $closureInClass = ClassConstantTest::getClosureInClass(); $closureInTrait = ClassConstantTest::getClosureInTrait(); echo 'Before bind: ' . PHP_EOL; echo '__CLASS__ in class: ' . PHP_EOL; var_dump($closureInClass()); echo '__CLASS__ in Trait: ' . PHP_EOL; var_dump($closureInTrait()); $closureInClass = Closure::bind($closureInClass, null, 'MyClass'); $closureInTrait = Closure::bind($closureInTrait, null, 'MyClass'); echo PHP_EOL . 'After bind: ' . PHP_EOL; echo '__CLASS__ in class: ' . PHP_EOL; var_dump($closureInClass()); echo '__CLASS__ in Trait: ' . PHP_EOL; var_dump($closureInTrait());

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.1.100.0040.00417.52
8.1.90.0030.00517.50
8.1.80.0040.00417.34
8.1.70.0040.00417.48
8.1.60.0000.00817.59
8.1.50.0060.00317.58
8.1.40.0050.00317.52
8.1.30.0040.00417.54
8.1.20.0030.00517.63
8.1.10.0040.00417.46
8.1.00.0080.00417.59
8.0.230.0030.00317.00
8.0.220.0030.00316.78
8.0.210.0040.00416.91
8.0.200.0030.00317.00
8.0.190.0000.00817.03
8.0.180.0070.00316.89
8.0.170.0040.00416.88
8.0.160.0030.00616.95
8.0.150.0030.00616.74
8.0.140.0000.00716.80
8.0.130.0030.00313.34
8.0.120.0150.00013.32
8.0.110.0130.00413.20
8.0.100.0160.00013.38
8.0.90.0090.00913.34
8.0.80.0130.00313.31
8.0.70.0120.00413.33
8.0.60.0160.00013.39
8.0.50.0160.00013.35
8.0.30.0160.00013.32
8.0.20.0120.00213.48
8.0.10.0170.00013.51
8.0.00.0030.00313.54
7.4.300.0040.00416.52
7.4.290.0000.00816.39
7.4.280.0040.00416.50
7.4.270.0050.00316.63
7.4.260.0030.00316.50
7.4.250.0110.00813.30
7.4.240.0170.00313.30
7.4.230.0130.00413.29
7.4.220.0130.00313.22
7.4.210.0130.00413.27
7.4.200.0130.00313.27
7.4.190.0110.00813.36
7.4.180.0180.00013.47
7.4.160.0150.00313.46
7.4.150.0150.00013.30
7.4.140.0110.00513.24
7.4.130.0120.00413.18
7.4.120.0160.00013.29
7.4.110.0070.00813.20
7.4.100.0100.00613.27
7.4.90.0090.00713.21
7.4.80.0080.00813.25
7.4.70.0130.00413.23
7.4.60.0090.00313.30
7.4.50.0130.00013.13
7.4.40.0110.00313.11
7.4.30.0060.00413.17
7.4.20.0060.00513.23
7.4.10.0030.00813.23
7.4.00.0130.00013.28
7.3.330.0060.00013.14
7.3.320.0110.00613.18
7.3.310.0110.00413.15
7.3.300.0120.00213.17
7.3.290.0100.00713.18
7.3.280.0120.00413.07
7.3.270.0140.00313.17
7.3.260.0140.00413.11
7.3.250.0040.00713.33
7.3.240.0100.00413.28
7.3.230.0140.00413.33
7.3.220.0150.00312.99
7.3.210.0150.00013.29
7.3.200.0160.00013.21
7.3.190.0100.00713.32
7.3.180.0110.00613.18
7.3.170.0200.00013.31
7.3.160.0160.00313.17
7.3.150.0130.00513.21
7.3.140.0180.00013.25
7.3.130.0140.00413.23
7.3.120.0130.00313.27
7.3.110.0140.00513.18
7.3.100.0140.00213.03
7.3.90.0180.00013.35
7.3.80.0140.00413.18
7.3.70.0180.00013.35
7.3.60.0130.00413.38
7.3.50.0180.00013.38
7.3.40.0110.00213.24
7.3.30.0120.00413.40
7.3.20.0160.00015.02
7.3.10.0100.00715.15
7.3.00.0120.00615.17

preferences:
25.86 ms | 411 KiB | 12 Q