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.0150.00016.63
8.3.50.0090.00616.36
8.3.40.0040.01118.88
8.3.30.0120.00619.01
8.3.20.0040.00420.45
8.3.10.0040.00423.83
8.3.00.0030.00523.79
8.2.180.0110.00316.63
8.2.170.0090.01322.96
8.2.160.0080.00620.47
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0030.00521.04
8.2.120.0040.00426.35
8.2.110.0060.00321.00
8.2.100.0120.00017.93
8.2.90.0040.00419.36
8.2.80.0050.00317.97
8.2.70.0000.00917.75
8.2.60.0050.00318.05
8.2.50.0040.00818.09
8.2.40.0060.00322.35
8.2.30.0030.00519.40
8.2.20.0000.00717.73
8.2.10.0000.00718.28
8.2.00.0000.00718.14
8.1.280.0070.01425.92
8.1.270.0050.00323.99
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0060.00322.54
8.1.230.0070.00319.04
8.1.220.0040.00417.78
8.1.210.0000.00818.77
8.1.200.0060.00317.36
8.1.190.0050.00317.25
8.1.180.0000.00818.10
8.1.170.0050.00518.71
8.1.160.0000.00720.79
8.1.150.0030.00620.63
8.1.140.0060.00319.63
8.1.130.0000.00717.63
8.1.120.0070.00017.50
8.1.110.0040.00417.55
8.1.100.0050.00217.45
8.1.90.0040.00417.54
8.1.80.0050.00517.37
8.1.70.0000.00717.45
8.1.60.0070.00017.61
8.1.50.0060.00317.49
8.1.40.0040.00417.51
8.1.30.0000.00817.66
8.1.20.0040.00417.71
8.1.10.0000.00817.51
8.1.00.0000.00817.44
8.0.300.0000.00718.77
8.0.290.0000.00816.88
8.0.280.0040.00418.47
8.0.270.0040.00417.21
8.0.260.0030.00317.32
8.0.250.0040.00417.08
8.0.240.0050.00516.97
8.0.230.0070.00016.94
8.0.220.0000.00716.89
8.0.210.0000.00716.98
8.0.200.0080.00016.93
8.0.190.0040.00417.05
8.0.180.0000.00816.93
8.0.170.0000.00816.96
8.0.160.0040.00417.08
8.0.150.0040.00416.88
8.0.140.0050.00316.93
8.0.130.0030.00313.57
8.0.120.0060.00316.91
8.0.110.0020.00516.89
8.0.100.0050.00317.00
8.0.90.0000.00716.84
8.0.80.0060.00916.96
8.0.70.0040.00416.99
8.0.60.0040.00416.87
8.0.50.0080.00016.88
8.0.30.0060.01417.16
8.0.20.0140.00817.40
8.0.10.0040.00417.09
8.0.00.0070.01116.84
7.4.330.0000.00516.89
7.4.320.0040.00416.60
7.4.300.0040.00416.53
7.4.290.0030.00316.63
7.4.280.0080.00016.51
7.4.270.0060.00016.60
7.4.260.0070.00416.47
7.4.250.0000.00816.59
7.4.240.0020.00516.43
7.4.230.0070.00016.60
7.4.220.0070.01116.71
7.4.210.0100.01116.67
7.4.200.0030.00316.52
7.4.160.0000.01516.31
7.4.150.0130.00617.40
7.4.140.0150.01217.86
7.4.130.0080.01016.61
7.4.120.0110.00616.63
7.4.110.0090.00916.55
7.4.100.0030.01416.40
7.4.90.0110.00716.57
7.4.80.0060.01119.39
7.4.70.0110.01216.54
7.4.60.0140.00316.57
7.4.50.0070.00716.52
7.4.40.0090.01216.41
7.4.30.0030.01416.66
7.4.00.0090.00915.32
7.3.330.0030.00313.42
7.3.320.0000.00513.38
7.3.310.0070.00016.49
7.3.300.0030.00316.46
7.3.290.0030.00316.43
7.3.280.0080.00916.42
7.3.270.0110.00717.40
7.3.260.0100.00716.50
7.3.250.0110.00716.59
7.3.240.0130.00316.64
7.3.230.0110.00516.45
7.3.210.0140.00416.43
7.3.200.0100.01019.39
7.3.190.0060.01016.41
7.3.180.0090.00616.55
7.3.170.0130.00916.39
7.3.160.0130.00316.45
7.3.10.0080.01216.41
7.3.00.0130.00316.29
7.2.330.0000.01816.81
7.2.320.0030.01416.52
7.2.310.0090.01216.70
7.2.300.0100.01016.75
7.2.290.0070.01016.61
7.2.130.0100.00716.96
7.2.120.0100.00616.59
7.2.110.0080.01116.76
7.2.100.0110.00716.76
7.2.90.0090.00916.71
7.2.80.0130.01016.36
7.2.70.0110.00716.61
7.2.60.0080.00517.02
7.2.50.0140.00416.59
7.2.40.0090.00616.43
7.2.30.0100.01017.10
7.2.20.0210.00516.31
7.2.10.0170.00716.38
7.2.00.0090.01418.14
7.1.250.0090.00615.56
7.1.200.0000.00715.91
7.1.100.0000.00918.24
7.1.70.0000.00717.25
7.1.60.0030.02019.40
7.1.50.0060.01617.02
7.1.00.0000.08022.33
7.0.200.0410.00314.55
7.0.60.0170.07321.55
7.0.50.0030.04317.94
7.0.40.0100.08320.30
7.0.30.0230.08320.16
7.0.20.0300.08320.24
7.0.10.0100.05720.06
7.0.00.0100.05720.07
5.6.280.0030.04721.15
5.6.210.0030.04020.68
5.6.200.0030.07318.22
5.6.190.0130.08020.63
5.6.180.0300.05020.63
5.6.170.0270.05020.58
5.6.160.0170.04020.47
5.6.150.0030.05718.21
5.6.140.0130.04018.19
5.6.130.0170.05718.14
5.6.120.0030.07321.16
5.6.110.0130.07021.13
5.6.100.0070.07721.05
5.6.90.0100.08021.02
5.6.80.0100.07720.49
5.5.350.0130.03720.34
5.5.340.0070.07317.94
5.5.330.0070.04320.40
5.5.320.0330.08020.29
5.5.310.0300.05020.24
5.5.300.0070.08317.95
5.5.290.0170.07317.98
5.5.280.0070.05720.82
5.5.270.0130.07720.81
5.5.260.0030.06020.91
5.5.250.0130.07320.79
5.5.240.0030.07020.28

preferences:
39.22 ms | 400 KiB | 5 Q