3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generateSignature($path, $payload, $secret, $expires) { // Create the canonical string from expires and path $canonical = "GET\n\n\n" . $expires . "\n" . $path . ($payload != null ? "\n" . $payload : ""); // for example GET 1452204987 /recoservice/1.0/recommendations/target/122711000061 containerCodes=a1wr-162ed67911cc // Encrypt it with secret $signatureBytes = hash_hmac("sha256", $canonical, $secret, true); // Base64 encode the encrypted results and URL encode the base64 return urlencode(base64_encode($signatureBytes)); } function generatecanonical($path, $payload, $secret, $expires) { // Create the canonical string from expires and path $canonical = "GET\n\n\n" . $expires . "\n" . $path . ($payload != null ? "\n" . $payload : ""); // for example GET 1452204987 /recoservice/1.0/recommendations/target/122711000061 containerCodes=a1wr-162ed67911cc // Base64 encode the encrypted results and URL encode the base64 return $canonical; } $secret = "wbVx3n5/pgW0dTV/6nhW8QOVdr5HiWfZoXp1AcIJGfU="; //this is your secret API key that you can find in the Settings page $a1accesskeyid = "507WRLEEPZSZFCKGFPKYOZJ"; //this is your public API key that you can find in the Settings page $containerCodes = [ 'a1wr-12ac7a9eb51a' //put your container codes here. No need for an array if you have only one container on that page ]; $targetId = "9780373622818"; //this is an example, $targetId should contain the variable you use on your page for your Product ID $expires = time() + 900; //this makes API calls reusable for up to 15 min (900sec). You can make this longer or shorter, as you prefer (but not longer than 1h) $pathToAgilOne = "/recoservice/1.0/recommendations/target/" . $targetId; $payload = htmlentities('containerCodes=' . implode(',', $containerCodes)); $signature = generateSignature($pathToAgilOne, $payload, $secret, $expires); $canonical = generatecanonical($pathToAgilOne, $payload, $secret, $expires); ?> <!DOCTYPE html> <html> <head> <title>A1 Electronics</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <style> body { padding: 50px; font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; } a { color: #00B7FF; } </style> </head> <body style="padding: 0; margin: 0;"> <!-- Your page content --> <div style="padding: 20px; border-bottom: 1px solid #ccc; background: #E6F1F7"> <div style="float: right;"> <a href="" style="text-decoration: none;">My Account | Wish List | Order Status | My Shopping Cart</a> <div style="margin-top: 20px;">We take everything, except DISCOVER!</div> </div> <h1 style="padding: 0; margin: 0; color: #006699">A1 Electronics</h1> <span>If we don't have what you're looking for, it doesn't exist</span> </div> <!-- The div in which we will place the AgilOne container (it's actually not necessary to encapsulate it in a div) --> <div style="padding: 20px;"> <div style="margin-bottom: 30px; overflow: hidden; width: 800px;"> <?php foreach ($containerCodes as $containerCode) { ?> <!-- note that this "for" loop isn't relevant for your website. You should put each div in the proper location for your website --> <div id="<?= $containerCode ?>" style="margin-bottom: 20px;"></div> <!-- this is the div containing the actual container, and where it will show on the page --> <?php } ?> </div> </div> <!-- This part below is for the AgilOne Webtag. Don't re-implement it if you already have it on your page. --> <script type='text/javascript'> var _a1as = _a1as || []; _a1as.push(["init","1234567"]); _a1as.push(["track"]); _a1as.push(["product_view", "<?= $targetId ?>"]); </script> <script type='text/javascript'> (function() { var a1s = document.createElement('script'); a1s.type = 'text/javascript'; a1s.async = true; a1s.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'tr-1.agilone.com/tr-as.js'; var a1ss = document.getElementsByTagName('script')[0]; a1ss.parentNode.insertBefore(a1s, a1ss); })(); </script> <!-- End of the AgilOne Webtag script --> <!-- This is the script for the AgilOne Web container --> <script type='text/javascript'> var _a1wr = { target: '<?php echo $targetId ?>', a1accesskeyid: '<?php echo $a1accesskeyid ?>', expires: '<?php echo $expires ?>', signature: '<?php echo $signature ?>', containerCode: '<?php echo implode(',', $containerCodes) ?>', apiHost: 'awrs.agilone.com', apiPort: window.location.protocol === 'http:' ? '8080' : '8443', _debug: true }; </script> <script src="//awrs.agilone.com/static/a1wr.min.js"></script> <!-- End of AgilOne Web container script --> <h1>signature is <?php echo $signature ?></h1> <h2> canonical is <?php echo $canonical ?> </h2> </body> </html>

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)
7.4.10.0030.01115.08
7.4.00.0080.00915.03
7.3.130.0090.01014.97
7.3.120.0140.00515.03
7.3.110.0070.01214.98
7.3.100.0020.01115.09
7.3.90.0050.01014.91
7.3.80.0070.00315.08
7.3.70.0030.01014.85
7.3.60.0030.00814.83
7.3.50.0050.00714.86
7.3.40.0090.00514.82
7.3.30.0090.00714.89
7.3.20.0040.01116.56
7.3.10.0060.00716.68
7.3.00.0030.00816.59
7.2.260.0070.01115.05
7.2.250.0070.00915.00
7.2.240.0060.00915.11
7.2.230.0070.00615.11
7.2.220.0030.01414.90
7.2.210.0030.01115.21
7.2.200.0080.00815.20
7.2.190.0040.01215.15
7.2.180.0060.00714.99
7.2.170.0050.00815.10
7.2.160.0090.00415.02
7.2.150.0040.01317.02
7.2.140.0060.00616.89
7.2.130.0060.00816.75
7.2.120.0060.00716.93
7.2.110.0050.00517.04
7.2.100.0050.00816.97
7.2.90.0030.01016.89
7.2.80.0080.00516.81
7.2.70.0070.00517.07
7.2.60.0040.00916.84
7.2.50.0050.00716.93
7.2.40.0050.00917.01
7.2.30.0100.00516.82
7.2.20.0030.01316.90
7.2.10.0040.01316.89
7.2.00.0040.01217.65
7.1.330.0050.01115.54
7.1.320.0030.00915.71
7.1.310.0090.00315.78
7.1.300.0030.01115.81
7.1.290.0070.00315.93
7.1.280.0100.00515.91
7.1.270.0080.00615.85
7.1.260.0050.00915.98
7.1.250.0060.00615.64
7.1.240.0070.01015.93
7.1.230.0050.00815.69
7.1.220.0070.00815.70
7.1.210.0030.00615.61
7.1.200.0060.00515.76
7.1.190.0070.00515.72
7.1.180.0030.01015.78
7.1.170.0070.00815.76
7.1.160.0090.00515.73
7.1.150.0030.01015.74
7.1.140.0080.00715.89
7.1.130.0070.00715.83
7.1.120.0060.00815.66
7.1.110.0030.00715.68
7.1.100.0010.01116.57
7.1.90.0120.00415.88
7.1.80.0070.00915.85
7.1.70.0050.00816.31
7.1.60.0380.01021.50
7.1.50.0350.00721.66
7.1.40.0390.00821.51
7.1.30.0510.01121.35
7.1.20.0410.00921.44
7.1.10.0260.00815.47
7.1.00.0280.01215.54
7.0.330.0020.01015.16
7.0.320.0030.00815.41
7.0.310.0050.00715.23
7.0.300.0070.00315.41
7.0.290.0060.00815.37
7.0.280.0030.00715.42
7.0.270.0110.00515.33
7.0.260.0030.00915.39
7.0.250.0060.00515.33
7.0.240.0050.01015.49
7.0.230.0030.01115.44
7.0.220.0060.00615.44
7.0.210.0050.01015.54
7.0.200.0250.00915.27
7.0.190.0260.01215.18
7.0.180.0300.01115.18
7.0.170.0390.01215.17
7.0.160.0320.00915.10
7.0.150.0390.00615.13
7.0.140.0330.00515.17
7.0.130.0220.01215.21
7.0.120.0310.00515.10
7.0.110.0250.00914.97
7.0.100.0500.00815.08
7.0.90.0270.00815.19
7.0.80.0290.00515.13
7.0.70.0260.01015.11
7.0.60.0230.00914.92
7.0.50.0260.01015.22
7.0.40.0260.00613.96
7.0.30.0230.00713.95
7.0.20.0240.00613.85
7.0.10.0290.00713.78
7.0.00.0310.01013.88
5.6.400.0070.00314.20
5.6.390.0030.00914.20
5.6.380.0060.00614.54
5.6.370.0020.01214.43
5.6.360.0060.00914.41
5.6.350.0080.00814.59
5.6.340.0050.00714.41
5.6.330.0050.00714.49
5.6.320.0080.00714.48
5.6.310.0060.00814.48
5.6.300.0040.00814.42
5.6.290.0060.00714.27
5.6.280.0080.00714.46
5.6.270.0090.00414.28
5.6.260.0030.00814.49
5.6.250.0050.00714.34
5.6.240.0050.01014.50
5.6.230.0080.00514.44
5.6.220.0040.00914.33
5.6.210.0070.00614.31
5.6.200.0090.00614.57
5.6.190.0050.00414.18
5.6.180.0060.01114.43
5.6.170.0050.00514.04
5.6.160.0030.01114.43
5.6.150.0050.00914.49
5.6.140.0030.00714.30
5.6.130.0050.00514.46
5.6.120.0060.00514.38
5.6.110.0070.00714.38
5.6.100.0050.00814.31
5.6.90.0090.00614.37
5.6.80.0060.00514.31
5.6.70.0050.00714.16
5.6.60.0020.00914.25
5.6.50.0030.00614.32
5.6.40.0080.00314.52
5.6.30.0070.00714.24
5.6.20.0060.00614.21
5.6.10.0100.00114.17
5.6.00.0060.00614.30

preferences:
35.93 ms | 400 KiB | 5 Q