3v4l.org

run code in 300+ PHP versions simultaneously
<?php function xor_encrypt($in) { $key = '<censored>'; $text = $in; $outText = ''; // Iterate through each character for($i=0;$i<strlen($text);$i++) { $outText .= $text[$i] ^ $key[$i % strlen($key)]; } return $outText; } // CALLED FIRST function loadData($def) { global $_COOKIE; $mydata = $def; // If data is in the cookie if(array_key_exists("data", $_COOKIE)) { // Get the data in rawform. base64 -> XORED -> json $tempdata = json_decode(xor_encrypt(base64_decode($_COOKIE["data"])), true); // outputs an assoc array with a key "showpassword" and "bgcolor" if(is_array($tempdata) && array_key_exists("showpassword", $tempdata) && array_key_exists("bgcolor", $tempdata)) { // If bg color looks like # + 6 of a-f then copy it over to mydata if (preg_match('/^#(?:[a-fd]{6})$/i', $tempdata['bgcolor'])) { $mydata['showpassword'] = $tempdata['showpassword']; $mydata['bgcolor'] = $tempdata['bgcolor']; } } } return $mydata; } // CALLED NEXT // go the other way function saveData($d) { setcookie("data", base64_encode(xor_encrypt(json_encode($d)))); } function decryptcookie($data){ $base64_decoded = base64_decode($data); $xored = xor_encrypt(base64_decode($data)); $json = json_decode(xor_encrypt(base64_decode($data)), true); $out = json_decode(xor_encrypt(base64_decode($data)), true); //////////////////////////////////////////////////////////////// echo "This is it:\n"; echo "HEXX: ". bin2hex($data)."\n"; echo "orig: ". $data."\n"; echo "base64 decoded: ".$base64_decoded."\n"; echo "xor: ".$xored."\n"; echo "json_decode: ".$json."\n"; echo "out: ". $out."\n\n"; //////////////////////////////////////////////////////////////// print_r($out); print_r(array_values($out)); echo "Type of based64:". gettype($base64_decoded)."\n"; echo "Type of xored:". gettype($xored)."\n"; echo "Type of json:". gettype($json)."\n"; echo "Type of out:". gettype($out); echo "\n****\n"; } ///////////////////////////////////////////// $defaultdata = array( "showpassword"=>"no", "bgcolor"=>"#ffffff"); // put the cookie data in the new data $data = loadData($defaultdata); // if the color is a valid hexcode then add it to the cookie if(array_key_exists("bgcolor",$_REQUEST)) { if (preg_match('/^#(?:[a-fd]{6})$/i', $_REQUEST['bgcolor'])) { $data['bgcolor'] = $_REQUEST['bgcolor']; } } saveData($data); $cook = "ClVLIh4ASCsCBE8lAxMacFMZV2hdVVotEhhUJQNVAmhSEV4sFxFeaAw="; $cook_alt = "ClVLIh4ASCsCBE8lAxMacFMZV2hdVVotEhhUJQNVAmhSEV4sFxFeaAw"; decryptcookie($cook); echo 'Hello World!';

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.01118.43
8.3.60.0050.01018.30
8.3.50.0110.00918.26
8.3.40.0100.01018.78
8.3.30.0150.00318.79
8.3.20.0120.00319.47
8.3.10.0040.00421.69
8.3.00.0000.00919.79
8.2.180.0140.01017.00
8.2.170.0090.00622.96
8.2.160.0120.00319.03
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0070.00020.57
8.2.120.0120.00026.35
8.2.110.0060.00320.54
8.2.100.0000.01117.91
8.2.90.0040.00419.21
8.2.80.0080.00017.97
8.2.70.0080.00017.63
8.2.60.0030.00618.03
8.2.50.0040.00418.10
8.2.40.0000.00820.51
8.2.30.0040.00419.26
8.2.20.0030.00518.25
8.2.10.0070.00018.24
8.2.00.0000.00718.36
8.1.280.0090.00625.92
8.1.270.0090.00023.99
8.1.260.0040.00426.35
8.1.250.0090.00028.09
8.1.240.0060.00324.02
8.1.230.0080.00319.16
8.1.220.0050.00317.78
8.1.210.0040.00418.77
8.1.200.0040.00417.48
8.1.190.0050.00317.35
8.1.180.0050.00318.10
8.1.170.0030.00518.63
8.1.160.0070.00018.82
8.1.150.0040.00420.23
8.1.140.0040.00419.56
8.1.130.0070.00018.95
8.1.120.0040.00417.44
8.1.110.0090.00017.59
8.1.100.0030.00517.58
8.1.90.0030.00517.57
8.1.80.0040.00417.57
8.1.70.0060.00317.48
8.1.60.0030.00617.61
8.1.50.0030.00517.50
8.1.40.0070.00317.59
8.1.30.0000.00817.60
8.1.20.0000.00717.74
8.1.10.0040.00417.65
8.1.00.0030.00517.48
8.0.300.0000.00720.14
8.0.290.0000.00816.88
8.0.280.0030.00318.43
8.0.270.0030.00317.24
8.0.260.0000.00618.98
8.0.250.0050.00217.13
8.0.240.0000.00716.98
8.0.230.0000.00717.07
8.0.220.0040.00416.90
8.0.210.0030.00517.06
8.0.200.0000.00717.13
8.0.190.0110.00017.14
8.0.180.0040.00417.05
8.0.170.0040.00417.05
8.0.160.0070.00016.91
8.0.150.0000.00816.96
8.0.140.0090.00017.02
8.0.130.0040.00413.41
8.0.120.0040.00416.99
8.0.110.0030.00516.89
8.0.100.0000.00716.91
8.0.90.0040.00417.05
8.0.80.0060.00917.02
8.0.70.0050.00216.86
8.0.60.0000.00817.09
8.0.50.0000.00716.92
8.0.30.0120.00817.26
8.0.20.0080.01217.40
8.0.10.0050.00317.18
8.0.00.0130.00616.91
7.4.330.0050.00215.55
7.4.320.0030.00316.67
7.4.300.0030.00316.55
7.4.290.0030.00316.71
7.4.280.0040.00416.64
7.4.270.0070.00016.56
7.4.260.0050.00216.55
7.4.250.0000.00816.52
7.4.240.0060.00316.64
7.4.230.0070.00016.78
7.4.220.0150.00316.70
7.4.210.0080.00916.56
7.4.200.0050.00216.31
7.4.160.0110.00716.69
7.4.150.0180.00017.40
7.4.140.0110.01017.86
7.4.130.0130.01316.52
7.4.120.0110.01216.64
7.4.110.0180.00016.60
7.4.100.0030.01516.64
7.4.90.0140.00316.56
7.4.80.0100.00719.39
7.4.70.0150.00916.48
7.4.60.0070.01016.41
7.4.50.0080.01116.65
7.4.40.0170.00716.40
7.4.30.0080.00916.29
7.4.00.0060.00314.61
7.3.330.0060.00013.41
7.3.320.0050.00013.42
7.3.310.0030.00316.45
7.3.300.0070.00016.32
7.3.290.0030.00616.41
7.3.280.0090.00816.47
7.3.270.0220.00017.40
7.3.260.0140.00616.58
7.3.250.0140.00616.58
7.3.240.0070.01216.64
7.3.230.0070.01116.62
7.3.210.0000.01716.41
7.3.200.0130.00316.38
7.3.190.0100.00616.69
7.3.180.0110.00716.56
7.3.170.0080.01116.44
7.3.160.0060.01016.60
7.2.330.0190.00416.82
7.2.320.0070.01716.92
7.2.310.0030.01216.70
7.2.300.0130.00416.85
7.2.290.0060.01216.93
7.2.60.0000.01316.79
7.2.00.0030.00919.52
7.1.200.0080.00315.93
7.1.70.0000.00716.92
7.1.60.0100.00017.38
7.1.50.0370.01033.08
7.1.40.0900.01032.54
7.1.30.0270.01332.59
7.1.20.0200.01732.80
7.1.10.0130.01014.69
7.1.00.0170.00714.84
7.0.200.0030.01316.79
7.0.190.0230.01014.56
7.0.180.0170.01014.39
7.0.170.0330.00714.39
7.0.160.0200.00314.44
7.0.150.0170.00714.61
7.0.140.0170.01014.54
7.0.130.0170.00314.59
7.0.120.0130.01014.72
7.0.110.0170.00714.44
7.0.100.0200.00314.64
7.0.90.0130.00714.61
7.0.80.0130.01014.54
7.0.70.0200.00714.43
7.0.60.0130.01314.39
7.0.50.0200.00314.46
7.0.40.0100.01314.78
7.0.30.0130.01314.57
7.0.20.0170.00714.51
7.0.10.0200.01314.71
7.0.00.0300.00014.62

preferences:
59.87 ms | 401 KiB | 5 Q