3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait ClosureInATrait { public static function getConstInTrait() { return __LINE__; } } 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 '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.3.60.0070.01416.63
8.3.50.0060.00921.92
8.3.40.0110.00718.83
8.3.30.0030.01219.08
8.3.20.0000.00820.29
8.3.10.0040.00423.66
8.3.00.0040.00420.68
8.2.180.0060.00916.88
8.2.170.0110.00422.96
8.2.160.0070.00720.53
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0020.00526.16
8.2.120.0000.00820.79
8.2.110.0060.00321.96
8.2.100.0120.00020.54
8.2.90.0030.00619.26
8.2.80.0050.00317.97
8.2.70.0030.00517.63
8.2.60.0000.00817.89
8.2.50.0030.00618.07
8.2.40.0000.00820.01
8.2.30.0040.00418.34
8.2.20.0000.00717.72
8.2.10.0020.00518.20
8.2.00.0050.00317.64
8.1.280.0040.01125.92
8.1.270.0040.00423.97
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0100.00022.23
8.1.230.0060.00619.09
8.1.220.0040.00417.74
8.1.210.0030.00518.77
8.1.200.0030.00617.47
8.1.190.0050.00317.23
8.1.180.0000.00818.10
8.1.170.0050.00318.57
8.1.160.0000.00722.08
8.1.150.0000.00718.70
8.1.140.0050.00217.39
8.1.130.0000.00717.84
8.1.120.0000.01217.42
8.1.110.0000.00717.54
8.1.100.0080.00017.49
8.1.90.0000.00717.48
8.1.80.0030.00317.55
8.1.70.0050.00217.39
8.1.60.0000.01017.60
8.1.50.0040.00417.53
8.1.40.0030.00517.54
8.1.30.0040.00417.52
8.1.20.0050.00317.62
8.1.10.0000.00917.59
8.1.00.0050.00317.55
8.0.300.0000.00718.77
8.0.290.0000.00816.75
8.0.280.0030.00318.45
8.0.270.0000.00717.27
8.0.260.0030.00317.28
8.0.250.0040.00417.02
8.0.240.0070.00017.05
8.0.230.0000.00716.95
8.0.220.0070.00016.93
8.0.210.0050.00216.87
8.0.200.0000.00716.92
8.0.190.0040.00416.94
8.0.180.0000.00717.03
8.0.170.0070.00017.03
8.0.160.0040.00316.84
8.0.150.0030.00616.94
8.0.140.0050.00216.89
8.0.130.0050.00013.45
8.0.120.0000.01016.90
8.0.110.0050.00316.97
8.0.100.0000.00817.00
8.0.90.0000.00716.87
8.0.80.0040.01116.96
8.0.70.0070.00017.00
8.0.60.0000.00717.09
8.0.50.0040.00417.01
8.0.30.0090.01117.09
8.0.20.0160.00617.40
8.0.10.0000.00716.95
8.0.00.0120.00716.95
7.4.330.0020.00215.00
7.4.320.0060.00016.62
7.4.300.0000.00616.51
7.4.290.0080.00016.52
7.4.280.0080.00016.36
7.4.270.0030.00316.43
7.4.260.0000.00716.39
7.4.250.0060.00316.54
7.4.240.0040.00416.58
7.4.230.0030.00316.49
7.4.220.0090.01416.63
7.4.210.0000.01516.51
7.4.200.0000.00716.64
7.4.190.0040.00416.51
7.4.160.0040.01616.61
7.4.150.0100.00817.40
7.4.140.0110.01017.86
7.4.130.0090.00816.67
7.4.120.0090.01216.49
7.4.110.0090.01516.36
7.4.100.0070.01116.64
7.4.90.0110.00616.64
7.4.80.0180.00319.39
7.4.70.0060.01016.33
7.4.60.0120.00616.68
7.4.50.0000.00916.53
7.4.40.0070.01016.49
7.4.30.0090.00616.35
7.4.00.0070.00714.91
7.3.330.0040.00413.16
7.3.320.0050.00013.31
7.3.310.0030.00316.38
7.3.300.0000.00716.36
7.3.290.0070.01316.30
7.3.280.0070.00916.32
7.3.270.0160.00417.40
7.3.260.0070.01016.30
7.3.250.0080.00916.54
7.3.240.0090.00916.38
7.3.230.0040.01216.39
7.3.210.0160.00616.64
7.3.200.0110.01119.39
7.3.190.0040.01216.54
7.3.180.0060.00916.35
7.3.170.0150.00616.52
7.3.160.0110.00616.39
7.3.120.0070.00714.72
7.2.330.0160.00716.61
7.2.320.0090.00916.44
7.2.310.0030.01316.29
7.2.300.0110.00616.70
7.2.290.0110.01116.28
7.2.110.0210.00716.56
7.2.60.0040.01116.73
7.1.200.0060.00615.86
7.1.70.0150.00317.27
7.1.60.0140.01019.70
7.1.50.0080.00817.01
7.1.00.0030.07722.43
7.0.200.0070.00316.82
7.0.140.0000.07722.08
7.0.60.0070.08319.92
7.0.50.0100.06717.99
7.0.40.0170.06020.30
7.0.30.0200.05020.16
7.0.20.0130.05020.19
7.0.10.0070.04320.18
7.0.00.0100.08720.15
5.6.280.0000.07320.86
5.6.210.0100.08020.60
5.6.200.0100.07318.24
5.6.190.0100.04720.48
5.6.180.3200.04320.63
5.6.170.0300.06320.71
5.6.160.0030.04320.50
5.6.150.0100.05018.12
5.6.140.0000.06318.21
5.6.130.0070.08018.19
5.6.120.0100.06721.07
5.6.110.0130.07721.02
5.6.100.0100.07020.98
5.6.90.0100.08321.02
5.6.80.0100.07320.39
5.6.70.4470.04020.37
5.5.350.0070.07020.38
5.5.340.0100.07317.96
5.5.330.0100.08320.21
5.5.320.0200.06720.30
5.5.310.0200.04020.27
5.5.300.0030.04017.95
5.5.290.0070.07318.01
5.5.280.0000.05020.80
5.5.270.0130.08020.98
5.5.260.0130.07020.88
5.5.250.0000.04720.43
5.5.240.0270.06020.16
5.4.450.0130.04719.50
5.4.440.0370.03719.37
5.4.430.0230.04019.63
5.4.420.0200.04719.48
5.4.410.0170.04719.42
5.4.400.0130.03719.32
5.4.390.0300.04319.23
5.4.380.0170.05718.80
5.4.370.0070.06318.72
5.4.360.0200.05018.72
5.4.350.0170.05318.59
5.4.340.0200.04718.78
5.4.320.0060.03612.50
5.4.310.0030.05012.50
5.4.300.0050.04112.50
5.4.290.0080.04012.50
5.4.280.0060.04512.39
5.4.270.0060.04012.39
5.4.260.0070.04112.40
5.4.250.0100.04312.39
5.4.240.0100.04412.39
5.4.230.0070.05212.39
5.4.220.0120.04612.39
5.4.210.0090.05412.39
5.4.200.0080.05612.39
5.4.190.0070.05412.38
5.4.180.0100.05012.38
5.4.170.0060.04312.39
5.4.160.0050.04212.39
5.4.150.0100.04012.39
5.4.140.0070.04012.07
5.4.130.0080.03712.06
5.4.120.0050.03812.02
5.4.110.0030.03912.01
5.4.100.0020.04012.01
5.4.90.0030.04312.02
5.4.80.0050.04012.01
5.4.70.0080.03412.00
5.4.60.0080.04312.01
5.4.50.0050.04012.01
5.4.40.0060.04212.00
5.4.30.0110.03012.00
5.4.20.0050.03911.99
5.4.10.0100.04811.99
5.4.00.0090.05011.48
5.3.290.0070.03812.80
5.3.280.0080.03912.70
5.3.270.0050.03912.72
5.3.260.0080.03712.71
5.3.250.0050.05012.72
5.3.240.0050.03812.72
5.3.230.0080.03712.71
5.3.220.0080.05312.68
5.3.210.0050.04112.68
5.3.200.0070.03612.68
5.3.190.0060.03612.68
5.3.180.0090.04212.68
5.3.170.0090.04412.67
5.3.160.0070.03912.67
5.3.150.0040.03912.67
5.3.140.0070.03912.66
5.3.130.0050.03812.66
5.3.120.0060.04012.66
5.3.110.0100.04612.66
5.3.100.0080.04712.12
5.3.90.0060.05412.09
5.3.80.0120.04512.07
5.3.70.0070.04112.07
5.3.60.0090.03512.06
5.3.50.0060.03712.00
5.3.40.0070.03612.00
5.3.30.0050.03611.95
5.3.20.0090.03511.73
5.3.10.0080.03811.70
5.3.00.0050.04011.68
5.2.170.0050.0309.18
5.2.160.0040.0309.18
5.2.150.0020.0339.18
5.2.140.0040.0419.18
5.2.130.0070.0409.14
5.2.120.0040.0359.14
5.2.110.0060.0329.15
5.2.100.0110.0309.14
5.2.90.0070.0369.14
5.2.80.0110.0319.14
5.2.70.0050.0369.13
5.2.60.0060.0349.09
5.2.50.0060.0299.05
5.2.40.0070.0359.04
5.2.30.0020.0339.01
5.2.20.0040.0309.00
5.2.10.0050.0288.92
5.2.00.0050.0318.78
5.1.60.0040.0328.07
5.1.50.0040.0248.06
5.1.40.0050.0258.04
5.1.30.0050.0258.40
5.1.20.0050.0258.42
5.1.10.0050.0248.14
5.1.00.0050.0248.14
5.0.50.0020.0226.62
5.0.40.0030.0236.48
5.0.30.0050.0326.29
5.0.20.0030.0226.26
5.0.10.0020.0236.25
5.0.00.0040.0416.24
4.4.90.0040.0224.78
4.4.80.0030.0194.75
4.4.70.0050.0154.75
4.4.60.0030.0174.76
4.4.50.0000.0184.77
4.4.40.0000.0284.71
4.4.30.0020.0164.76
4.4.20.0070.0114.85
4.4.10.0030.0164.85
4.4.00.0020.0284.76
4.3.110.0020.0174.67
4.3.100.0020.0164.66
4.3.90.0010.0164.63
4.3.80.0070.0214.58
4.3.70.0020.0154.63
4.3.60.0020.0154.63
4.3.50.0050.0194.63
4.3.40.0040.0264.54
4.3.30.0030.0153.28
4.3.20.0020.0163.26
4.3.10.0010.0163.22
4.3.00.0070.02051.50

preferences:
34.37 ms | 401 KiB | 5 Q