[php-src] Issue #12106: if query parameter value processing is different when value is empty or null
| From: | HeenaBansal2009 | Date: | Sat, 02 Sep 2023 10:06:29 +0000 |
| Subject: | [php-src] Issue #12106: if query parameter value processing is different when value is empty or null | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245316@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12106
Author: HeenaBansal2009
### Description
The following code:
CASE 1:
```
<?php
$url = "http://localhost:8964/?soap";
CASE1:
parse_url($url);
echo var_dump(parse_url($url));
$query = parse_str(parse_url($url)["query"], $result);
echo var_dump($result);
$http_query = http_build_query($result);
echo $http_query;
//CASE2 assign query param value to null
$result["soap"]=null;
echo $http_query;
//CASE 3 - replicate same as case 2 but in other form and results are different.
$arr = array('test' => null);
echo http_build_query($arr);
?>
```
```
array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
string(9) "localhost"
["port"]=>
int(8964)
["path"]=>
string(1) "/"
["query"]=>
string(4) "soap"
}
array(1) {
["soap"]=>
string(0) ""
}
soap=soap=
```
But I expected this output instead:
CASE1: soap=
CASE2: soap
CASE3 soap
PS: if query param value is empty string or null , but query param should be in url.
### PHP Version
PHP 8.1.2
### Operating System
_No response_