3v4l.org

run code in 300+ PHP versions simultaneously
<?php function setSessionTestingData() { $agent = 5; $ticket = 6; $_SESSION = array( 'agent_id' => '2', 'ticket_id' => '3', 'agent' => $agent, 'ticket' => $ticket, 'sub_array' => array( 'sub' => 4, 'agent' => $agent, 'ticket' => $ticket, ), ); return $_SESSION; } function getKey($session_key, $is_object_of_type = null) { $current_key = ''; $counter = 0; try { $session_keys_array = explode(':', $session_key); //checking if keys and value exist foreach ($session_keys_array as $key) { $counter++; $current_key .= '[\'' . $key . '\']'; if (!$_SESSION) { throw new Exception("\$_SESSION does not Exist"); } $prev_step = $_SESSION; if (array_key_exists($key, $prev_step) && count($session_keys_array) > $counter) { eval('$prevStep = $_SESSION' . $current_key . ';'); if (!is_array($prev_step) && count($session_keys_array) > $counter) { throw new Exception ("\$_SESSION$current_key is not an array"); } } else if ( is_array($prev_step) && eval('array_key_exists(' . $current_key . ', $_SESSION);') && count($session_keys_array) == $counter ) { eval('$result = $_SESSION' . $current_key . ';'); } else { throw new Exception("\$_SESSION$current_key does not Exist"); } } //checking if value is of right type if (!empty($is_object_of_type) && !$result instanceof $is_object_of_type) { throw new Exception("\$_SESSION$current_key is not instance of $is_object_of_type"); } //if we are here that means we have all safe data } catch(Exception $e) { //TODO:change Exception to SessionException and log this $result = null; } return $result; } $_SESSION = setSessionTestingData(); echo getKey('agent_id'); echo getKey('ticket_id'); echo getKey('sub_array:sub');

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.0000.01816.75
8.3.50.0110.00821.34
8.3.40.0070.00718.82
8.3.30.0120.00618.83
8.3.20.0040.00420.21
8.3.10.0030.00523.66
8.3.00.0000.00821.64
8.2.180.0120.00316.75
8.2.170.0110.01122.96
8.2.160.0100.00320.53
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0080.00021.05
8.2.120.0070.00026.35
8.2.110.0060.00319.27
8.2.100.0080.00417.93
8.2.90.0050.00319.36
8.2.80.0040.00417.97
8.2.70.0060.00317.75
8.2.60.0000.00918.03
8.2.50.0000.01018.09
8.2.40.0030.00522.38
8.2.30.0040.00419.63
8.2.20.0040.00417.88
8.2.10.0070.00018.06
8.2.00.0000.00818.18
8.1.280.0070.00725.92
8.1.270.0030.00623.99
8.1.260.0070.00028.09
8.1.250.0040.00428.09
8.1.240.0090.00022.46
8.1.230.0040.00717.76
8.1.220.0050.00317.74
8.1.210.0030.00618.77
8.1.200.0060.00317.35
8.1.190.0080.00017.23
8.1.180.0040.00418.10
8.1.170.0060.00318.72
8.1.160.0030.00520.79
8.1.150.0100.00018.92
8.1.140.0000.00819.59
8.1.130.0030.00317.52
8.1.120.0030.00317.43
8.1.110.0050.00217.37
8.1.100.0000.00817.45
8.1.90.0000.00717.43
8.1.80.0060.00317.49
8.1.70.0030.00317.53
8.1.60.0000.00817.50
8.1.50.0040.00417.53
8.1.40.0050.00317.59
8.1.30.0060.00317.69
8.1.20.0000.00717.55
8.1.10.0000.00717.50
8.1.00.0070.00017.57
8.0.300.0000.00718.77
8.0.290.0020.00516.75
8.0.280.0030.00318.39
8.0.270.0000.00717.26
8.0.260.0050.00216.85
8.0.250.0000.00717.02
8.0.240.0030.00616.97
8.0.230.0030.00316.93
8.0.220.0050.00317.03
8.0.210.0000.00716.93
8.0.200.0000.00917.09
8.0.190.0040.00416.89
8.0.180.0060.00317.03
8.0.170.0030.00517.03
8.0.160.0040.00417.04
8.0.150.0050.00316.86
8.0.140.0100.00016.82
8.0.130.0000.00613.35
8.0.120.0000.00816.91
8.0.110.0040.00416.85
8.0.100.0050.00316.84
8.0.90.0030.00516.92
8.0.80.0060.00916.92
8.0.70.0080.00016.90
8.0.60.0000.00816.79
8.0.50.0050.00217.05
8.0.30.0120.01017.29
8.0.20.0120.01017.40
8.0.10.0000.00717.14
8.0.00.0100.00816.78
7.4.330.0050.00016.81
7.4.320.0030.00316.53
7.4.300.0030.00316.57
7.4.290.0000.00716.61
7.4.280.0050.00316.65
7.4.270.0030.00316.52
7.4.260.0070.00316.60
7.4.250.0080.00016.51
7.4.240.0030.00416.62
7.4.230.0000.00716.43
7.4.220.0130.01316.60
7.4.210.0040.01116.60
7.4.200.0030.00316.50
7.4.160.0080.00816.57
7.4.150.0080.01217.40
7.4.140.0170.01017.86
7.4.130.0130.00516.49
7.4.120.0070.01016.60
7.4.110.0140.00416.41
7.4.100.0140.00316.66
7.4.90.0040.01416.63
7.4.80.0150.00319.39
7.4.70.0070.01516.66
7.4.60.0130.00316.48
7.4.50.0100.00316.22
7.4.40.0070.01116.50
7.4.30.0070.01116.53
7.4.10.0090.00915.26
7.4.00.0050.01115.06
7.3.330.0030.00313.45
7.3.320.0030.00313.25
7.3.310.0040.00416.48
7.3.300.0030.00316.35
7.3.290.0000.00716.43
7.3.280.0080.01216.44
7.3.270.0150.00417.40
7.3.260.0070.01016.44
7.3.250.0120.00816.55
7.3.240.0160.00216.62
7.3.230.0070.01016.41
7.3.210.0090.00916.46
7.3.200.0070.01119.39
7.3.190.0000.01816.36
7.3.180.0070.01016.39
7.3.170.0030.01416.62
7.3.160.0170.00016.56
7.3.130.0070.01014.72
7.3.120.0070.01115.02
7.3.110.0050.01214.94
7.3.100.0060.00814.78
7.3.90.0080.00614.83
7.3.80.0050.01014.99
7.3.70.0050.00514.70
7.3.60.0040.00914.75
7.3.50.0080.00814.78
7.3.40.0030.01014.75
7.3.30.0050.00714.95
7.3.20.0080.00416.70
7.3.10.0040.00616.71
7.3.00.0060.00716.74
7.2.330.0090.00916.52
7.2.320.0120.00616.81
7.2.310.0110.01516.67
7.2.300.0060.01316.66
7.2.290.0200.00016.52
7.2.260.0060.00615.16
7.2.250.0060.00915.10
7.2.240.0110.00615.11
7.2.230.0020.01315.11
7.2.220.0060.00815.26
7.2.210.0090.00615.01
7.2.200.0030.01015.09
7.2.190.0060.01114.94
7.2.180.0060.00614.99
7.2.170.0070.00815.03
7.2.160.0060.00914.91
7.2.150.0090.00417.09
7.2.140.0040.01417.07
7.2.130.0060.00716.87
7.2.120.0110.00516.93
7.2.110.0030.01016.77
7.2.100.0050.00716.96
7.2.90.0100.00316.93
7.2.80.0040.00917.08
7.2.70.0080.00716.92
7.2.60.0030.00816.88
7.2.50.0030.00916.84
7.2.40.0090.00417.05
7.2.30.0130.00217.02
7.2.20.0050.00716.88
7.2.10.0030.00817.00
7.2.00.0030.00917.69
7.1.330.0040.01115.77
7.1.320.0070.00815.70
7.1.310.0050.00715.60
7.1.300.0050.00915.76
7.1.290.0060.00615.74
7.1.280.0070.00815.97
7.1.270.0020.01315.66
7.1.260.0030.00915.71
7.1.250.0030.00915.80
7.1.240.0080.00015.79
7.1.230.0030.00615.80
7.1.220.0080.00415.67
7.1.210.0040.00815.82
7.1.200.0110.00315.65
7.1.190.0060.00615.88
7.1.180.0030.00715.96
7.1.170.0050.00315.76
7.1.160.0070.00415.57
7.1.150.0030.01015.75
7.1.140.0000.00915.94
7.1.130.0080.00415.99
7.1.120.0030.00915.72
7.1.110.0030.01015.82
7.1.100.0120.00616.31
7.1.90.0110.00315.85
7.1.80.0070.00715.65
7.1.70.0050.00716.60
7.1.60.0090.01117.47
7.1.50.0050.01216.48
7.1.40.0000.01415.64
7.1.30.0040.01115.46
7.1.20.0030.00615.95
7.1.10.0040.00715.74
7.1.00.0060.03819.20
7.0.330.0060.00315.54
7.0.320.0060.00315.44
7.0.310.0030.01015.39
7.0.300.0040.00815.48
7.0.290.0000.00915.52
7.0.280.0060.00615.48
7.0.270.0110.00415.50
7.0.260.0030.00515.38
7.0.250.0000.01315.49
7.0.240.0000.01115.42
7.0.230.0030.00715.31
7.0.220.0030.01015.27
7.0.210.0100.00715.43
7.0.200.0210.00714.95
7.0.190.0080.00615.14
7.0.180.0030.01315.23
7.0.170.0030.00515.42
7.0.160.0090.00315.30
7.0.150.0100.00315.58
7.0.140.0070.01015.22
7.0.130.0030.00615.58
7.0.120.0030.01015.61
7.0.110.0030.01015.56
7.0.100.0060.00615.12
7.0.90.0040.00715.54
7.0.80.0100.00315.30
7.0.70.0100.00015.50
7.0.60.0120.03218.58
7.0.50.0020.04016.76
7.0.40.0120.03016.79
7.0.30.0080.03016.91
7.0.20.0200.04216.85
7.0.10.0070.04516.74
7.0.00.0020.02416.69
5.6.400.0030.00714.74
5.6.390.0110.00414.30
5.6.380.0060.00314.59
5.6.370.0030.00914.23
5.6.360.0090.00314.28
5.6.350.0070.00714.52
5.6.340.0060.01014.05
5.6.330.0040.01214.67
5.6.320.0040.00714.70
5.6.310.0060.00614.23
5.6.300.0030.01213.91
5.6.290.0070.00714.32
5.6.280.0040.02517.49
5.6.270.0070.00714.29
5.6.260.0100.00314.60
5.6.250.0030.01014.53
5.6.240.0030.01014.71
5.6.230.0060.00314.36
5.6.220.0070.00714.57
5.6.210.0060.02117.51
5.6.200.0050.03316.34
5.6.190.0070.04217.46
5.6.180.0200.02817.56
5.6.170.0170.03717.66
5.6.160.0100.02717.44
5.6.150.0050.03216.47
5.6.140.0060.04516.24
5.6.130.0100.04316.23
5.6.120.0120.03817.74
5.6.110.0090.04117.77
5.6.100.0110.04317.75
5.6.90.0090.04317.76
5.6.80.0080.04017.20
5.6.70.0060.00614.50
5.6.60.0040.00714.41
5.6.50.0090.00614.35
5.6.40.0030.01014.46
5.6.30.0060.00314.34
5.6.20.0000.01114.27
5.6.10.0040.00814.40
5.6.00.0060.00314.20
5.5.380.0090.00614.31
5.5.370.0120.00314.36
5.5.360.0000.00914.53
5.5.350.0170.01717.50
5.5.340.0110.04116.26
5.5.330.0080.02617.36
5.5.320.0120.03417.31
5.5.310.0200.03217.33
5.5.300.0080.02316.34
5.5.290.0050.04716.29
5.5.280.0030.04817.77
5.5.270.0030.03817.70
5.5.260.0080.03517.52
5.5.250.0050.04417.51
5.5.240.0080.03117.25
5.5.230.0030.00614.41
5.5.220.0040.01214.35
5.5.210.0000.00914.32
5.5.200.0100.00314.26
5.5.190.0070.00314.41
5.5.180.0030.00914.40
5.5.170.0110.00014.29
5.5.160.0100.00014.27
5.5.150.0000.01114.15
5.5.140.0000.01514.50
5.5.130.0120.00314.21
5.5.120.0080.00814.13
5.5.110.0040.01114.39
5.5.100.0140.00014.38
5.5.90.0070.00314.31
5.5.80.0030.00914.26
5.5.70.0040.00714.21
5.5.60.0000.01214.16
5.5.50.0060.01014.20
5.5.40.0110.00314.58
5.5.30.0100.00314.45
5.5.20.0080.00814.50
5.5.10.0060.00614.07
5.5.00.0040.01114.20

preferences:
32.55 ms | 401 KiB | 5 Q