3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Response { public function __construct(protected $targetUrl = ''){} public function getTargetUrl(): string { return $this->targetUrl; } public function setTargetUrl(string $target_url): void { $this->targetUrl = $target_url; } } $withQuery = new Response('https://example.com?foo=bar'); $withoutQuery = new Response('https://example.com?'); $withoutQuestion = new Response('https://example.com'); function queryManip(Response $response): Response { // The 'destination' parameter should remain in the query but be // unused by the target_url. $target_url = $response->getTargetUrl(); if (str_contains($target_url, '?')) { $query_string = parse_url($target_url, PHP_URL_QUERY) ?: ''; parse_str($query_string, $query); $target_url = substr($target_url, 0, strpos($target_url, '?')) . '?' . http_build_query($query); } $response->setTargetUrl($target_url); return $response; } echo sprintf('With query: %s%s', queryManip($withQuery)->getTargetUrl(), \PHP_EOL); echo sprintf('Without query: %s%s', queryManip($withoutQuery)->getTargetUrl(), \PHP_EOL); echo sprintf('Without question: %s%s', queryManip($withoutQuestion)->getTargetUrl(), \PHP_EOL);

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.120.0040.00420.77
8.3.110.0040.00420.94
8.3.100.0040.00424.06
8.3.90.0040.00426.77
8.3.80.0090.00318.43
8.3.70.0120.00318.30
8.3.60.0130.01020.46
8.3.50.0070.01516.76
8.3.40.0070.00722.28
8.3.30.0100.00320.23
8.3.20.0080.00024.18
8.3.10.0050.00224.66
8.3.00.0040.00426.16
8.2.240.0060.00318.88
8.2.230.0060.00322.58
8.2.220.0090.00037.54
8.2.210.0090.00926.77
8.2.200.0060.00316.50
8.2.190.0130.00916.75
8.2.180.0140.00718.48
8.2.170.0120.00322.96
8.2.160.0090.00622.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0060.00326.16
8.2.120.0050.00322.04
8.2.110.0070.00421.04
8.2.100.0090.00319.24
8.2.90.0030.00617.84
8.2.80.0000.00720.38
8.2.70.0130.00679.33
8.2.60.0120.00879.33
8.2.50.0190.00079.33
8.2.40.0110.00779.33
8.2.30.0080.00879.33
8.2.20.0120.00579.33
8.2.10.0200.00079.33
8.2.00.0140.00379.33
8.1.300.0060.00320.30
8.1.290.0040.00830.84
8.1.280.0040.01125.92
8.1.270.0070.01124.66
8.1.260.0040.00428.09
8.1.250.0050.00328.09
8.1.240.0050.00522.24
8.1.230.0100.00020.81
8.1.220.0040.00417.74
8.1.210.0000.00918.86
8.1.200.0100.00779.33
8.1.190.0140.00379.33
8.1.180.0140.00379.33
8.1.170.0040.01279.33
8.1.160.0180.00079.33
8.1.150.0150.00279.33
8.1.140.0130.00379.33
8.1.130.0160.00079.33
8.1.120.0090.00979.33
8.1.110.0120.00479.33
8.1.100.0160.00079.33
8.1.90.0180.00079.33
8.1.80.0150.00479.33
8.1.70.0030.01379.33
8.1.60.0140.00679.33
8.1.50.0090.00979.33
8.1.40.0120.00679.33
8.1.30.0170.00079.33
8.1.20.0180.00079.33
8.1.10.0150.00379.33
8.1.00.0090.00979.33
8.0.300.0030.00620.09
8.0.290.0080.00879.33
8.0.280.0130.00579.33
8.0.270.0150.00379.33
8.0.260.0090.00979.33
8.0.250.0110.00779.33
8.0.240.0140.00379.33
8.0.230.0100.00679.33
8.0.220.0140.00479.33
8.0.210.0120.00679.33
8.0.200.0170.00079.33
8.0.190.0070.01079.33
8.0.180.0130.00379.33
8.0.170.0080.00879.33
8.0.160.0150.00379.33
8.0.150.0140.00579.33
8.0.140.0050.01179.33
8.0.130.0160.00379.33
8.0.120.0160.00079.33
8.0.110.0100.00679.33
8.0.100.0100.00779.33
8.0.90.0100.00779.33
8.0.80.0170.00079.33
8.0.70.0160.00379.33
8.0.60.0130.00379.33
8.0.50.0130.00379.33
8.0.30.0140.00379.33
8.0.20.0120.00479.33
8.0.10.0120.00579.33

preferences:
44.48 ms | 403 KiB | 5 Q