Permalink
Browse files

Allow for query strings such as: ...?foo

git-svn-id: http://svn.php.net/repository/pear/packages/Net_URL/trunk@103851 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 2e3fb52 commit bbc2126900811ed0484daf39c69dc222e59b15f8 Richard Heyes committed Nov 14, 2002
Showing with 5 additions and 3 deletions.
  1. +5 −3 URL.php
View
@@ -121,7 +121,7 @@ function Net_URL($url = null)
$this->host = !empty($host) ? $host : (isset($HTTP_SERVER_VARS['SERVER_NAME']) ? $HTTP_SERVER_VARS['SERVER_NAME'] : 'localhost');
$this->port = !empty($port) ? $port : (isset($HTTP_SERVER_VARS['SERVER_PORT']) ? $HTTP_SERVER_VARS['SERVER_PORT'] : 80);
$this->path = $HTTP_SERVER_VARS['PHP_SELF'];
- $this->querystring = $this->_parseRawQuerystring($HTTP_SERVER_VARS['QUERY_STRING']);
+ $this->querystring = isset($HTTP_SERVER_VARS['QUERY_STRING']) ? $this->_parseRawQuerystring($HTTP_SERVER_VARS['QUERY_STRING']) : null;
$this->anchor = '';
// Parse the uri and store the various parts
@@ -252,8 +252,10 @@ function getQueryString()
foreach ($value as $k => $v) {
$querystring[] = sprintf('%s[%s]=%s', $name, $k, $v);
}
- } else {
+ } elseif ($value) {
$querystring[] = $name . '=' . $value;
+ } else {
+ $querystring[] = $name;
}
}
$querystring = implode('&', $querystring);
@@ -281,7 +283,7 @@ function _parseRawQuerystring($querystring)
$value[$k] = rawurlencode($v);
}
$qs[$key] = $value;
- } else {
+ } elseif ($value) {
$qs[$key] = rawurlencode($value);
}
}

0 comments on commit bbc2126

Please sign in to comment.