3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace WoohooLabs\Yang\JsonApi\Request; use Psr\Http\Message\RequestInterface; class RequestBuilder { /** * @var \Psr\Http\Message\RequestInterface */ protected $request; /** * @var string */ protected $method; /** * @var array */ protected $queryString; /** * @param \Psr\Http\Message\RequestInterface $request */ public function __construct() { $this->initialize(); } public function initialize() { $this->method = "GET"; $this->queryString = []; } public function fetch() { $this->method = "GET"; } public function create() { $this->method = "POST"; } public function update() { $this->method = "PATCH"; } public function delete() { $this->method = "DELETE"; } /** * @param array|string $fields */ public function fields($fields) { $this->setQueryParam("fields", $fields); } /** * @param array|string $fields */ public function sort($fields) { $this->setQueryParam("sort", $fields); } /** * @param array|string $paginate */ public function paginate($paginate) { $this->setQueryParam("page", $paginate); } /** * @param array|string $filter */ public function filter($filter) { $this->setQueryParam("filter", $filter); } /** * @param array|string $includes */ public function includes($includes) { if (is_array($includes)) { $this->queryString["includes"] = implode(",", $includes); } else { $this->queryString["includes"] = $includes; } } /** * @return \Psr\Http\Message\RequestInterface */ public function getRequest() { $request = $this->request->withMethod($this->method); $request = $request->withUri($request->getUri()->withQuery($this->getQueryString())); return $request; } /** * @return string */ public function getQueryString() { return http_build_query($this->queryString); } /** * @param string $name * @param array|string $queryParam */ protected function setQueryParam($name, $queryParam) { if (is_array($queryParam)) { foreach ($queryParam as $key => $value) { $this->queryString[$name][$key] = $queryParam; } } else { $this->queryString[$name] = $queryParam; } } /** * @param array $array * @return bool */ protected function isAssociativeArray(array $array) { return (bool)count(array_filter(array_keys($array), 'is_string')); } } $builder = new RequestBuilder(); $builder->fields(["kaka" => "1,2,3,4", "shohoh" => "6,5,4,3"]); echo url_decode($builder->getQueryString());

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.0120.00918.39
8.3.50.0140.00416.40
8.3.40.0110.00418.79
8.3.30.0090.00618.83
8.3.20.0000.00820.29
8.3.10.0050.00323.51
8.3.00.0040.00417.89
8.2.180.0140.00718.41
8.2.170.0120.00322.96
8.2.160.0070.00720.35
8.2.150.0030.00724.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0100.00017.63
8.2.110.0080.00022.24
8.2.100.0060.00619.48
8.2.90.0030.00619.22
8.2.80.0000.00817.97
8.2.70.0000.00817.75
8.2.60.0000.00818.16
8.2.50.0030.00518.07
8.2.40.0030.00619.36
8.2.30.0040.00420.60
8.2.20.0040.00417.91
8.2.10.0070.00018.15
8.2.00.0000.00818.09
8.1.280.0110.00725.92
8.1.270.0030.01422.15
8.1.260.0060.00326.35
8.1.250.0000.00828.09
8.1.240.0040.00422.66
8.1.230.0120.00017.48
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0030.00617.35
8.1.190.0080.00017.35
8.1.180.0050.00318.10
8.1.170.0000.00818.57
8.1.160.0040.00422.05
8.1.150.0020.00518.93
8.1.140.0030.00517.53
8.1.130.0070.00017.74
8.1.120.0050.00217.54
8.1.110.0040.00417.54
8.1.100.0040.00417.54
8.1.90.0070.00017.53
8.1.80.0030.00617.48
8.1.70.0000.00717.39
8.1.60.0000.00817.65
8.1.50.0040.00417.43
8.1.40.0000.00917.55
8.1.30.0000.00917.61
8.1.20.0040.00417.72
8.1.10.0000.00817.61
8.1.00.0040.00417.50
8.0.300.0040.00418.77
8.0.290.0060.00316.88
8.0.280.0070.00018.48
8.0.270.0030.00317.17
8.0.260.0030.00317.25
8.0.250.0070.00017.06
8.0.240.0040.00417.04
8.0.230.0070.00017.09
8.0.220.0030.00316.90
8.0.210.0070.00016.89
8.0.200.0090.00017.09
8.0.190.0000.00716.95
8.0.180.0080.00016.99
8.0.170.0030.00616.91
8.0.160.0040.00416.98
8.0.150.0040.00416.93
8.0.140.0040.00416.93
8.0.130.0060.00013.46
8.0.120.0000.00916.99
8.0.110.0030.00516.93
8.0.100.0040.00416.86
8.0.90.0000.00716.79
8.0.80.0110.01216.93
8.0.70.0000.00716.94
8.0.60.0030.00316.89
8.0.50.0040.00416.94
8.0.30.0110.00817.12
8.0.20.0100.01217.40
8.0.10.0040.00417.16
8.0.00.0110.00816.73
7.4.330.0000.00515.08
7.4.320.0000.00616.63
7.4.300.0040.00416.47
7.4.290.0000.00716.62
7.4.280.0030.00616.54
7.4.270.0050.00316.54
7.4.260.0000.00816.64
7.4.250.0040.00416.47
7.4.240.0040.00316.50
7.4.230.0040.00416.74
7.4.220.0160.01116.67
7.4.210.0030.01216.66
7.4.200.0030.00516.57
7.4.160.0120.00316.48
7.4.150.0160.00417.40
7.4.140.0120.00917.86
7.4.130.0110.00616.51
7.4.120.0120.00816.59
7.4.110.0100.00716.49
7.4.100.0120.01316.50
7.4.90.0170.00616.65
7.4.80.0070.01119.39
7.4.70.0190.00316.54
7.4.60.0070.01016.63
7.4.50.0090.00016.21
7.4.40.0170.00016.58
7.4.30.0070.01416.63
7.4.00.0000.01414.80
7.3.330.0000.00513.39
7.3.320.0000.00713.32
7.3.310.0000.00716.30
7.3.300.0040.00416.37
7.3.290.0100.00816.41
7.3.280.0080.00916.43
7.3.270.0140.00717.40
7.3.260.0120.00916.62
7.3.250.0030.01516.56
7.3.240.0130.00316.52
7.3.230.0070.01016.53
7.3.210.0100.01016.67
7.3.200.0050.01116.75
7.3.190.0060.01616.40
7.3.180.0030.01416.73
7.3.170.0050.01116.49
7.3.160.0130.00416.54
7.2.330.0090.00916.73
7.2.320.0030.01416.73
7.2.310.0000.01616.78
7.2.300.0090.01216.80
7.2.290.0090.01216.58
7.2.60.0040.01217.00
7.2.00.0030.01019.26
7.1.200.0000.01415.71
7.1.100.0070.00718.25
7.1.70.0070.00717.19
7.1.60.0160.00019.19
7.1.50.0040.00716.85
7.1.00.0000.07722.48
7.0.200.0000.01016.74
7.0.60.0130.08020.05
7.0.50.0030.08717.90
7.0.40.0170.04320.10
7.0.30.0170.04020.34
7.0.20.0300.07720.33
7.0.10.0270.07720.09
7.0.00.0170.07320.33
5.6.280.0070.06720.94
5.6.210.0070.04320.68
5.6.200.0030.06718.21
5.6.190.0030.08720.61
5.6.180.0330.07320.46
5.6.170.0400.07020.45
5.6.160.0070.06720.52
5.6.150.0030.04018.17
5.6.140.0070.03718.22
5.6.130.0230.06718.18
5.6.120.0070.08320.92
5.6.110.0100.06321.04
5.6.100.0130.05721.01
5.6.90.0100.08021.03
5.6.80.0130.08020.53
5.6.70.0270.06020.53
5.5.350.0170.06720.52
5.5.340.0000.04318.07
5.5.330.0070.06320.13
5.5.320.0130.07320.43
5.5.310.0300.07020.23
5.5.300.0030.05017.94
5.5.290.0070.03717.98
5.5.280.0200.07020.87
5.5.270.0070.04020.77
5.5.260.0070.04720.70
5.5.250.0070.08020.60
5.5.240.0070.06320.26
5.4.450.1370.00019.59
5.4.440.1600.00019.30
5.4.430.1370.00019.47
5.4.420.1770.00019.53
5.4.410.1530.00019.16
5.4.400.1230.00019.36
5.4.390.1400.00019.24
5.4.380.1330.00018.84
5.4.370.1200.00018.84
5.4.360.1230.00018.87
5.4.350.1300.00019.28
5.4.340.1330.00019.26
5.4.320.1630.00018.85
5.4.310.1230.00019.00
5.4.300.1270.00019.30
5.4.290.1200.00019.27
5.4.280.1230.00019.26
5.4.270.1200.00019.21
5.4.260.1200.00019.14
5.4.250.1200.00019.25
5.4.240.1200.00019.23
5.4.230.1230.00019.11
5.4.220.1530.00018.96
5.4.210.1370.00019.27
5.4.200.1370.00018.88
5.4.190.1330.00018.88
5.4.180.1070.00018.96
5.4.170.1070.00018.82
5.4.160.1370.00019.22
5.4.150.1430.00018.85
5.4.140.1270.00016.47
5.4.130.1170.00016.34
5.4.120.1130.00016.27
5.4.110.1230.00016.63
5.4.100.1130.00016.41
5.4.90.1230.00016.20
5.4.80.1200.00016.56
5.4.70.0030.07016.61
5.4.60.0000.03716.55
5.4.50.0000.07316.44
5.4.40.0070.06716.43
5.4.30.0030.03316.57
5.4.20.0370.06016.50
5.4.10.0230.05016.56

preferences:
68.29 ms | 401 KiB | 5 Q