3v4l.org

run code in 300+ PHP versions simultaneously
<?php class parentUserId { private $parentId = ''; function __construct($childid) { // convert given long int into binary it must be 64 bit long $binary = $this->dec2bin_long($childid); //trim first 16 char $binary = substr($binary, 0, 16); //add '0' in the right side upto string length get 64 $binary = str_pad($binary, 64, 0, STR_PAD_RIGHT); //Convet new binary into decimal $this->parentId = $this->bin2dec_long($binary); } public function getParentId() { return $this->parentId; } private function dec2bin_long($decimal_i) { bcscale(0); $binary_i = ''; do { $binary_i = bcmod($decimal_i, '2') . $binary_i; $decimal_i = bcdiv($decimal_i, '2'); } while (bccomp($decimal_i, '0')); return str_pad($binary_i, 64, 0, STR_PAD_LEFT); } private function bin2dec_long($binary_i) { bcscale(0); $decimal_i = '0'; for ($i = 0; $i < strlen($binary_i); $i++) { $decimal_i = bcmul($decimal_i, '2'); $decimal_i = bcadd($decimal_i, $binary_i[$i]); } return($decimal_i); } } $obj = new parentUserId("4335559066275177789"); echo $obj->getParentId(); ?>

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.70.0110.00718.25
8.3.60.0110.00716.75
8.3.50.0130.00522.11
8.3.40.0070.00718.84
8.3.30.0130.00318.85
8.3.20.0040.00420.14
8.3.10.0080.00021.91
8.3.00.0040.00419.38
8.2.180.0110.00418.16
8.2.170.0100.00322.96
8.2.160.0100.00320.39
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00017.75
8.2.110.0060.00321.05
8.2.100.0090.00317.97
8.2.90.0000.00917.85
8.2.80.0060.00319.48
8.2.70.0000.00817.87
8.2.60.0030.00618.16
8.2.50.0080.00018.10
8.2.40.0030.00620.42
8.2.30.0000.00720.72
8.2.20.0040.00417.85
8.2.10.0040.00418.15
8.2.00.0000.00718.02
8.1.280.0000.01425.92
8.1.270.0000.00823.82
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0060.00322.09
8.1.230.0080.00319.04
8.1.220.0000.00817.79
8.1.210.0030.00618.77
8.1.200.0070.00317.35
8.1.190.0040.00417.35
8.1.180.0030.00518.10
8.1.170.0030.00518.48
8.1.160.0000.00822.05
8.1.150.0000.00719.01
8.1.140.0000.00819.61
8.1.130.0050.00317.74
8.1.120.0000.00717.40
8.1.110.0070.00017.53
8.1.100.0000.00817.51
8.1.90.0040.00417.39
8.1.80.0050.00317.47
8.1.70.0030.00317.48
8.1.60.0040.00417.61
8.1.50.0030.01017.49
8.1.40.0030.00517.56
8.1.30.0040.00417.69
8.1.20.0000.00717.67
8.1.10.0000.00817.59
8.1.00.0000.00717.44
8.0.300.0040.00419.68
8.0.290.0050.00216.58
8.0.280.0000.00718.47
8.0.270.0030.00317.27
8.0.260.0000.00617.20
8.0.250.0050.00216.99
8.0.240.0040.00416.90
8.0.230.0000.00916.86
8.0.220.0070.00016.93
8.0.210.0040.00416.79
8.0.200.0030.00316.96
8.0.190.0040.00416.86
8.0.180.0040.00416.93
8.0.170.0050.00316.89
8.0.160.0000.00717.04
8.0.150.0000.00816.77
8.0.140.0080.00016.82
8.0.130.0060.00013.31
8.0.120.0000.00816.96
8.0.110.0040.00416.91
8.0.100.0050.00216.78
8.0.90.0040.00416.82
8.0.80.0110.01116.86
8.0.70.0040.00416.75
8.0.60.0030.00516.99
8.0.50.0040.00416.91
8.0.30.0060.01017.12
8.0.20.0120.00717.40
8.0.10.0040.00417.07
8.0.00.0090.01116.80
7.4.330.0030.00315.08
7.4.320.0000.00616.54
7.4.300.0000.00816.54
7.4.290.0030.00316.54
7.4.280.0050.00316.57
7.4.270.0000.00716.67
7.4.260.0080.00016.57
7.4.250.0040.00416.64
7.4.240.0050.00316.55
7.4.230.0030.00316.63
7.4.220.0040.01416.48
7.4.210.0110.00816.56
7.4.200.0000.00716.61
7.4.160.0000.01616.54
7.4.150.0070.01017.40
7.4.140.0100.01117.86
7.4.130.0000.01916.48
7.4.120.0100.00616.50
7.4.110.0040.01416.47
7.4.100.0070.01016.41
7.4.90.0090.01216.64
7.4.80.0090.00919.39
7.4.70.0070.01416.52
7.4.60.0110.00616.69
7.4.50.0000.00516.40
7.4.40.0090.01216.64
7.4.30.0140.00416.25
7.4.00.0070.01115.06
7.3.330.0050.00013.19
7.3.320.0060.00013.24
7.3.310.0000.00816.41
7.3.300.0040.00416.27
7.3.290.0070.00016.25
7.3.280.0110.00616.39
7.3.270.0160.00317.40
7.3.260.0100.01016.41
7.3.240.0050.01316.46
7.3.230.0230.00016.49
7.3.210.0090.00916.46
7.3.200.0100.00716.43
7.3.190.0030.01616.70
7.3.180.0130.00316.36
7.3.170.0090.01216.38
7.3.160.0060.01016.49
7.3.10.0080.00316.73
7.3.00.0080.00316.38
7.2.330.0090.00916.45
7.2.320.0120.00916.56
7.2.310.0100.00716.71
7.2.300.0140.00416.83
7.2.290.0110.01116.67
7.2.130.0000.01016.98
7.2.120.0030.00916.78
7.2.110.0110.00416.64
7.2.100.0090.00616.95
7.2.90.0070.00716.94
7.2.80.0070.01016.77
7.2.70.0000.01117.04
7.2.60.0090.00416.94
7.2.50.0090.00616.86
7.2.40.0060.00617.05
7.2.30.0000.01116.71
7.2.20.0150.00016.79
7.2.10.0120.00316.75
7.2.00.0050.00818.24
7.1.250.0070.00415.43
7.1.200.0030.01015.93
7.1.100.0030.00718.34
7.1.70.0070.01016.97
7.1.60.0100.01419.48
7.1.50.0080.00816.97
7.1.00.0030.07722.44
7.0.200.0310.00414.88
7.0.60.0030.04320.03
7.0.50.0100.06317.91
7.0.40.0070.04020.14
7.0.30.0170.07320.17
7.0.20.0270.07020.03
7.0.10.0100.08320.24
7.0.00.0100.06720.06
5.6.280.0130.06321.13
5.6.210.0070.05020.70
5.6.200.0100.05718.27
5.6.190.0030.06720.55
5.6.180.0300.07720.58
5.6.170.0270.08020.56
5.6.160.0030.04720.56
5.6.150.0030.04318.19
5.6.140.0000.08718.27
5.6.130.0070.05718.13
5.6.120.0070.04021.04
5.6.110.0100.07021.00
5.6.100.0100.07321.02
5.6.90.0070.08320.98
5.6.80.0070.03720.49
5.5.350.4030.04720.34
5.5.340.0030.07017.96
5.5.330.0030.06320.35
5.5.320.0230.04320.27
5.5.310.0370.07720.34
5.5.300.0170.06717.95
5.5.290.0100.05318.02
5.5.280.0100.04020.99
5.5.270.0070.08320.78
5.5.260.0100.08320.88
5.5.250.0170.07320.72
5.5.240.0100.03720.30

preferences:
68.03 ms | 401 KiB | 5 Q