3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait ClosureInATrait { public static function getConstInTrait() { return __CLASS__; } } class ClassConstantTest { use ClosureInATrait; public static function getConstInClass() { return __CLASS__; } } $closureInClass = (new ReflectionMethod('ClassConstantTest','getConstInClass'))->getClosure(); $closureInTrait = (new ReflectionMethod('ClassConstantTest','getConstInTrait'))->getClosure(); 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, 'stdClass'); $closureInTrait = Closure::bind($closureInTrait, null, 'stdClass'); 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.0050.00317.45
8.1.90.0040.00417.48
8.1.80.0040.00417.41
8.1.70.0070.00017.42
8.1.60.0040.00417.63
8.1.50.0030.00517.45
8.1.40.0050.00317.58
8.1.30.0040.00417.58
8.1.20.0030.00517.73
8.1.10.0030.00517.53
8.1.00.0000.00817.44
8.0.230.0040.00417.06
8.0.220.0030.00317.02
8.0.210.0030.00516.98
8.0.200.0000.00817.01
8.0.190.0040.00417.04
8.0.180.0070.00016.93
8.0.170.0000.00816.97
8.0.160.0040.00416.90
8.0.150.0000.00716.77
8.0.140.0020.00516.88
8.0.130.0000.00613.42
8.0.120.0050.00316.90
8.0.110.0050.00316.89
8.0.100.0000.00816.84
8.0.90.0000.00816.98
8.0.80.0060.01017.00
8.0.70.0080.00016.81
8.0.60.0040.00416.75
8.0.50.0080.00016.87
8.0.30.0110.00717.27
8.0.20.0090.00917.40
8.0.10.0000.00717.05
8.0.00.0100.00916.75
7.4.300.0030.00316.52
7.4.290.0030.00316.66
7.4.280.0080.00016.52
7.4.270.0030.00316.52
7.4.260.0000.00716.59
7.4.250.0040.00416.63
7.4.240.0020.00516.54
7.4.230.0050.00216.41
7.4.220.0160.00316.55
7.4.210.0130.00616.65
7.4.200.0030.00516.67
7.4.190.0040.00416.49
7.4.160.0060.01516.71
7.4.150.0040.01317.40
7.4.140.0140.00417.86
7.4.130.0070.01116.48
7.4.120.0080.01016.65
7.4.110.0070.01316.66
7.4.100.0100.00716.70
7.4.90.0060.01216.55
7.4.80.0110.00619.39
7.4.70.0040.01216.60
7.4.60.0150.00416.34
7.4.50.0080.00016.37
7.4.40.0130.00416.37
7.4.30.0120.00316.45
7.4.00.0030.01315.05
7.3.330.0070.00013.35
7.3.320.0030.00213.12
7.3.310.0000.00716.14
7.3.300.0050.00216.19
7.3.290.0080.00816.38
7.3.280.0080.01216.34
7.3.270.0130.00317.40
7.3.260.0130.00816.44
7.3.250.0110.00716.46
7.3.240.0040.01316.53
7.3.230.0070.01016.57
7.3.210.0040.01516.49
7.3.200.0100.00719.39
7.3.190.0120.00616.52
7.3.180.0060.00916.43
7.3.170.0050.01416.60
7.3.160.0120.00416.46
7.3.120.0000.01114.84
7.3.10.0000.01316.56
7.3.00.0070.00716.63
7.2.330.0110.00716.59
7.2.320.0040.01316.70
7.2.310.0070.01016.70
7.2.300.0090.00916.60
7.2.290.0080.01416.66
7.2.130.0100.00316.76
7.2.120.0070.01016.88
7.2.110.0000.01116.89
7.2.100.0060.01316.90
7.2.90.0150.00916.97
7.2.80.0150.00916.69
7.2.70.0130.00317.05
7.2.60.0070.00916.88
7.2.50.0130.00316.83
7.2.40.0100.01016.66
7.2.30.0090.00916.94
7.2.20.0080.00816.82
7.2.10.0040.00816.93
7.2.00.0090.00818.04
7.1.250.0070.00415.51
7.1.200.0040.00415.71
7.1.100.0070.00418.31
7.1.70.0050.00316.88
7.1.60.0110.01419.70
7.1.50.0060.01116.57
7.1.00.0030.07722.45
7.0.200.0000.00916.54
7.0.140.0100.06721.98
7.0.60.0100.04319.88
7.0.50.0030.08717.74
7.0.40.0070.07320.27
7.0.30.0130.05020.30
7.0.20.0230.05720.24
7.0.10.0070.05020.05
7.0.00.0100.07320.23
5.6.280.0070.07021.08
5.6.210.0170.07020.50
5.6.200.0100.07718.13
5.6.190.0070.08320.52
5.6.180.0370.07720.55
5.6.170.0400.04020.57
5.6.160.0130.05320.41
5.6.150.0030.04018.16
5.6.140.0170.05718.21
5.6.130.0170.03018.15
5.6.120.0000.04721.02
5.6.110.0030.08721.02
5.6.100.0070.07721.04
5.6.90.0130.04021.03
5.6.80.0100.04720.42
5.5.350.0230.06720.53
5.5.340.0170.03718.00
5.5.330.0130.08020.35
5.5.320.0430.08020.38
5.5.310.0370.06320.19
5.5.300.0070.06718.04
5.5.290.0100.07717.91
5.5.280.0100.08320.78
5.5.270.0070.07720.88
5.5.260.0130.07720.65
5.5.250.0130.08020.70
5.5.240.0070.07320.38
5.4.450.0470.04319.39
5.4.440.0070.05319.32
5.4.430.0300.04319.27
5.4.420.0300.03719.21
5.4.410.0070.03719.03
5.4.400.0970.04018.84
5.4.390.0200.03019.02
5.4.380.0070.06018.81
5.4.370.0170.05018.75
5.4.360.0100.06318.51
5.4.350.0200.04718.78
5.4.340.0200.04718.51
5.4.320.0070.04612.50
5.4.310.0080.03712.50
5.4.300.0070.04212.50
5.4.290.0060.05312.50
5.4.280.0100.04612.39
5.4.270.0080.04512.40
5.4.260.0060.04112.39
5.4.250.0040.04112.39
5.4.240.0080.03612.40
5.4.230.0100.03612.39
5.4.220.0060.03812.38
5.4.210.0080.03512.39
5.4.200.0050.03912.39
5.4.190.0080.03512.38
5.4.180.0060.03812.38
5.4.170.0050.03812.39
5.4.160.0080.03412.39
5.4.150.0060.03612.39
5.4.140.0060.03812.07
5.4.130.0050.03712.06
5.4.120.0070.03512.01
5.4.110.0090.04112.01
5.4.100.0080.04112.01
5.4.90.0050.03912.01
5.4.80.0070.03812.02
5.4.70.0080.03912.01
5.4.60.0090.03512.01
5.4.50.0090.05612.01
5.4.40.0070.03712.00
5.4.30.0070.03912.00
5.4.20.0060.03511.99
5.4.10.0050.04112.00
5.4.00.0130.05311.48
5.3.290.0090.04812.80
5.3.280.0170.10812.71
5.3.270.0080.08612.72
5.3.260.0060.04412.72
5.3.250.0090.03412.72
5.3.240.0070.03612.72
5.3.230.0060.03912.71
5.3.220.0080.03712.68
5.3.210.0080.03712.68
5.3.200.0120.03112.68
5.3.190.0090.03512.67
5.3.180.0090.04112.68
5.3.170.0060.03712.67
5.3.160.0030.03912.68
5.3.150.0040.04012.67
5.3.140.0060.03712.66
5.3.130.0090.03512.66
5.3.120.0040.04212.66
5.3.110.0080.03712.66
5.3.100.0080.03512.12
5.3.90.0080.03512.09
5.3.80.0090.03612.07
5.3.70.0060.03712.07
5.3.60.0070.03612.06
5.3.50.0110.03412.00
5.3.40.0070.03712.00
5.3.30.0110.03311.95
5.3.20.0060.03911.73
5.3.10.0040.03811.70
5.3.00.0080.03511.68
5.2.170.0070.0309.18
5.2.160.0060.0279.18
5.2.150.0060.0289.18
5.2.140.0030.0329.18
5.2.130.0040.0309.14
5.2.120.0050.0289.14
5.2.110.0060.0299.14
5.2.100.0060.0289.14
5.2.90.0030.0319.14
5.2.80.0070.0289.14
5.2.70.0080.0289.14
5.2.60.0050.0309.09
5.2.50.0060.0299.06
5.2.40.0020.0339.03
5.2.30.0040.0309.02
5.2.20.0040.0309.00
5.2.10.0050.0288.93
5.2.00.0020.0328.79
5.1.60.0040.0278.06
5.1.50.0050.0248.06
5.1.40.0060.0278.05
5.1.30.0060.0258.40
5.1.20.0040.0278.41
5.1.10.0060.0268.14
5.1.00.0030.0288.14
5.0.50.0050.0216.62
5.0.40.0110.0356.48
5.0.30.0030.0316.29
5.0.20.0020.0236.27
5.0.10.0030.0226.24
5.0.00.0040.0306.23
4.4.90.0030.0154.78
4.4.80.0050.0124.75
4.4.70.0040.0144.75
4.4.60.0030.0154.75
4.4.50.0050.0354.77
4.4.40.0030.0254.71
4.4.30.0010.0184.76
4.4.20.0020.0164.84
4.4.10.0020.0164.85
4.4.00.0050.0234.76
4.3.110.0020.0164.67
4.3.100.0050.0144.67
4.3.90.0040.0144.64
4.3.80.0040.0254.59
4.3.70.0030.0154.63
4.3.60.0030.0154.63
4.3.50.0050.0144.63
4.3.40.0030.0284.54
4.3.30.0070.0253.29
4.3.20.0020.0193.26
4.3.10.0040.0193.22
4.3.00.0030.01316.92

preferences:
12.59 ms | 406 KiB | 5 Q