3v4l.org

run code in 300+ PHP versions simultaneously
<?php function setSessionTestingData() { $agent = new Agent(); $ticket = new Ticket(); $_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($_SESSION' . $current_key . ');') && 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($session_key);

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.0070.01018.30
8.3.60.0120.00316.50
8.3.50.0080.01021.27
8.3.40.0090.00618.97
8.3.30.0040.01118.81
8.3.20.0080.00020.30
8.3.10.0060.00322.08
8.3.00.0080.00023.53
8.2.190.0120.00316.63
8.2.180.0140.00016.61
8.2.170.0210.00022.96
8.2.160.0140.00020.38
8.2.150.0000.00824.18
8.2.140.0060.00324.66
8.2.130.0050.00321.05
8.2.120.0050.00226.35
8.2.110.0060.00320.93
8.2.100.0090.00317.90
8.2.90.0070.00019.08
8.2.80.0000.00817.97
8.2.70.0060.00317.48
8.2.60.0040.00417.80
8.2.50.0100.00318.09
8.2.40.0040.00422.10
8.2.30.0080.00019.40
8.2.20.0050.00217.73
8.2.10.0050.00218.02
8.2.00.0040.00418.04
8.1.280.0110.00425.92
8.1.270.0140.00023.99
8.1.260.0070.00028.09
8.1.250.0080.00028.09
8.1.240.0030.00722.31
8.1.230.0070.00419.16
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0030.00617.22
8.1.190.0040.00417.25
8.1.180.0000.00818.10
8.1.170.0000.00818.62
8.1.160.0040.00420.66
8.1.150.0030.00618.81
8.1.140.0000.00819.40
8.1.130.0060.00317.53
8.1.120.0050.00217.29
8.1.110.0050.00317.25
8.1.100.0000.00817.28
8.1.90.0080.00017.26
8.1.80.0030.00317.25
8.1.70.0030.00317.41
8.1.60.0040.00417.59
8.1.50.0080.00017.51
8.1.40.0030.00617.45
8.1.30.0030.00517.70
8.1.20.0070.00017.62
8.1.10.0040.00417.43
8.1.00.0030.00517.50
8.0.300.0080.00018.77
8.0.290.0050.00316.75
8.0.280.0070.00018.41
8.0.270.0050.00317.21
8.0.260.0050.00317.22
8.0.250.0030.00317.00
8.0.240.0000.01016.90
8.0.230.0040.00417.02
8.0.220.0020.00516.93
8.0.210.0070.00016.91
8.0.200.0040.00416.88
8.0.190.0040.00416.86
8.0.180.0040.00416.91
8.0.170.0030.00516.92
8.0.160.0030.00616.93
8.0.150.0030.00716.88
8.0.140.0060.00316.84
8.0.130.0030.00313.33
8.0.120.0040.00416.77
8.0.110.0000.00816.79
8.0.100.0040.00416.87
8.0.90.0000.00716.81
8.0.80.0090.00616.91
8.0.70.0040.00416.79
8.0.60.0000.00816.84
8.0.50.0000.00817.04
8.0.30.0170.00316.93
8.0.20.0120.00717.40
8.0.10.0040.00416.86
8.0.00.0110.00716.79
7.4.330.0020.00216.69
7.4.320.0030.00316.39
7.4.300.0040.00416.48
7.4.290.0050.00316.62
7.4.280.0040.00416.38
7.4.270.0000.00716.60
7.4.260.0060.00316.44
7.4.250.0080.00016.39
7.4.240.0040.00416.55
7.4.230.0080.00016.37
7.4.220.0040.01516.36
7.4.210.0100.01016.56
7.4.200.0000.00716.37
7.4.160.0060.00916.46
7.4.150.0130.00617.40
7.4.140.0150.01017.86
7.4.130.0140.00616.56
7.4.120.0080.00916.60
7.4.110.0100.00716.69
7.4.100.0070.01116.42
7.4.90.0060.01016.61
7.4.80.0140.00319.39
7.4.70.0000.02116.69
7.4.60.0120.00616.40
7.4.50.0060.00916.21
7.4.40.0120.00616.31
7.4.30.0060.01216.55
7.4.00.0050.01215.20
7.3.330.0030.00313.34
7.3.320.0050.00013.29
7.3.310.0000.00816.37
7.3.300.0070.00016.33
7.3.290.0030.00316.25
7.3.280.0100.01016.31
7.3.270.0150.00717.40
7.3.260.0130.00416.42
7.3.250.0100.00816.41
7.3.240.0100.00816.43
7.3.230.0100.00716.61
7.3.210.0030.01416.30
7.3.200.0030.01619.39
7.3.190.0090.00616.50
7.3.180.0100.00716.41
7.3.170.0080.01116.35
7.3.160.0120.00316.25
7.3.120.0110.00815.02
7.3.110.0110.00714.98
7.3.100.0130.00614.44
7.3.90.0000.00814.78
7.3.80.0060.01214.85
7.3.70.0000.00914.86
7.3.60.0120.00014.91
7.3.50.0060.00914.86
7.3.40.0060.01014.50
7.3.30.0060.00314.82
7.3.20.0000.00816.48
7.3.10.0060.00916.83
7.3.00.0040.01416.84
7.2.330.0100.00716.57
7.2.320.0100.00716.64
7.2.310.0160.00716.30
7.2.300.0120.01216.53
7.2.290.0050.01016.56
7.2.250.0060.01215.04
7.2.240.0070.01014.91
7.2.230.0060.00914.94
7.2.220.0000.01214.88
7.2.210.0110.00715.16
7.2.200.0030.00914.91
7.2.190.0100.00714.96
7.2.180.0030.01214.84
7.2.170.0070.01014.97
7.2.160.0060.00914.93
7.2.150.0030.01416.87
7.2.140.0040.01116.75
7.2.130.0000.01116.85
7.2.120.0000.01416.85
7.2.110.0100.00716.88
7.2.100.0000.01416.91
7.2.90.0080.00416.54
7.2.80.0050.00716.53
7.2.70.0060.00616.60
7.2.60.0050.00816.79
7.2.50.0030.00716.66
7.2.40.0110.00316.82
7.2.30.0030.01216.84
7.2.20.0040.00716.57
7.2.10.0040.01116.81
7.2.00.0080.00517.96
7.1.330.0040.01115.53
7.1.320.0060.00915.68
7.1.310.0130.00015.70
7.1.300.0030.00615.64
7.1.290.0040.00715.40
7.1.280.0040.01215.76
7.1.270.0080.00415.70
7.1.260.0070.01015.68
7.1.250.0000.00915.69
7.1.240.0030.01115.63
7.1.230.0030.00815.54
7.1.220.0110.00415.25
7.1.210.0030.00915.38
7.1.200.0130.00515.72
7.1.190.0060.00615.36
7.1.180.0060.00915.71
7.1.170.0030.00915.50
7.1.160.0090.00615.43
7.1.150.0040.00715.74
7.1.140.0030.00915.43
7.1.130.0090.00615.68
7.1.120.0040.00715.63
7.1.110.0030.00615.76
7.1.100.0040.00716.81
7.1.90.0120.00315.43
7.1.80.0030.01115.72
7.1.70.0040.00416.24
7.1.60.0080.01017.49
7.1.50.0080.00716.14
7.1.40.0070.00715.73
7.1.30.0080.00815.41
7.1.20.0070.00715.53
7.1.10.0060.00315.61
7.1.00.0000.04719.03
7.0.330.0080.00415.23
7.0.320.0070.01015.34
7.0.310.0030.01415.33
7.0.300.0030.00515.21
7.0.290.0040.01115.05
7.0.280.0070.00315.17
7.0.270.0070.00715.45
7.0.260.0030.01015.24
7.0.250.0040.00415.38
7.0.240.0070.00315.14
7.0.230.0090.00315.04
7.0.220.0080.00815.25
7.0.210.0070.00414.89
7.0.200.0200.00914.85
7.0.190.0060.00615.30
7.0.180.0090.00315.36
7.0.170.0030.01015.39
7.0.160.0030.00715.39
7.0.150.0040.01115.39
7.0.140.0000.01515.20
7.0.130.0070.00315.21
7.0.120.0060.00915.38
7.0.110.0030.01415.32
7.0.100.0030.01315.44
7.0.90.0000.01215.43
7.0.80.0060.00915.43
7.0.70.0040.00815.35
7.0.60.0100.02317.51
7.0.50.0050.02716.70
7.0.40.0080.02616.72
7.0.30.0100.03216.76
7.0.20.0200.03816.80
7.0.10.0070.02716.84
7.0.00.0070.03516.76
5.6.400.0030.00914.21
5.6.390.0070.00414.29
5.6.380.0030.00913.87
5.6.370.0040.00414.46
5.6.360.0060.00914.08
5.6.350.0030.01014.16
5.6.340.0000.01414.29
5.6.330.0090.00614.46
5.6.320.0060.00314.40
5.6.310.0000.01113.99
5.6.300.0030.01214.19
5.6.290.0090.00014.56
5.6.280.0050.03517.79
5.6.270.0000.00914.09
5.6.260.0060.00314.12
5.6.250.0060.00314.23
5.6.240.0060.00914.26
5.6.230.0090.00014.33
5.6.220.0120.00314.39
5.6.210.0050.04617.42
5.6.200.0020.04616.23
5.6.190.0070.04817.27
5.6.180.0200.02717.43
5.6.170.0100.02817.54
5.6.160.0090.02917.36
5.6.150.0050.03916.11
5.6.140.0050.02716.16
5.6.130.0050.03816.21
5.6.120.0030.04817.68
5.6.110.0030.02517.56
5.6.100.0030.02917.53
5.6.90.0090.01917.36
5.6.80.0050.02717.28
5.6.70.0070.00714.31
5.6.60.0000.01114.07
5.6.50.0080.00814.27
5.6.40.0030.01314.38
5.6.30.0040.00713.98
5.6.20.0000.01214.23
5.6.10.0080.00814.03
5.6.00.0070.00714.34
5.5.380.0070.00714.05
5.5.370.0040.00414.09
5.5.360.0060.01014.05
5.5.350.0120.04017.24
5.5.340.0130.04016.12
5.5.330.0100.04117.18
5.5.320.0150.03617.26
5.5.310.0140.02617.16
5.5.300.0070.04416.12
5.5.290.0070.04715.90
5.5.280.0070.02417.50
5.5.270.0150.04017.46
5.5.260.0030.02317.30
5.5.250.0040.04317.42
5.5.240.0060.02117.01
5.5.230.0030.01313.98
5.5.220.0040.00814.16
5.5.210.0070.00314.11
5.5.200.0000.00913.81
5.5.190.0000.00914.16
5.5.180.0060.00913.83
5.5.170.0100.00314.02
5.5.160.0060.00614.07
5.5.150.0040.00814.16
5.5.140.0040.00814.14
5.5.130.0100.00313.72
5.5.120.0070.00713.93
5.5.110.0070.00714.12
5.5.100.0060.00614.25
5.5.90.0040.00813.86
5.5.80.0080.00014.10
5.5.70.0060.00614.01
5.5.60.0150.00413.62
5.5.50.0070.01114.04
5.5.40.0030.00613.84
5.5.30.0060.00313.90
5.5.20.0070.00713.93
5.5.10.0030.01114.33
5.5.00.0060.00914.07

preferences:
81.91 ms | 401 KiB | 5 Q