Url::add_url_parameter(): make $value parameter optional
This commit is contained in:
parent
5b54abb7af
commit
23a40c9680
1 changed files with 7 additions and 3 deletions
10
src/Url.php
10
src/Url.php
|
@ -538,17 +538,21 @@ class Url {
|
|||
*
|
||||
* @param string $url The URL
|
||||
* @param string $parameter The parameter name
|
||||
* @param string $value The parameter value
|
||||
* @param string|null $value The parameter value (optional)
|
||||
* @param boolean $encode Set if parameter value must be URL encoded (optional, default: true)
|
||||
*
|
||||
* @return string The completed URL
|
||||
*/
|
||||
public static function add_url_parameter($url, $parameter, $value, $encode=true) {
|
||||
public static function add_url_parameter($url, $parameter, $value=null, $encode=true) {
|
||||
if (strpos($url, '?') === false)
|
||||
$url .= '?';
|
||||
else
|
||||
$url .= '&';
|
||||
$url .= "$parameter=".($encode?urlencode($value):$value);
|
||||
$url .= (
|
||||
is_null($value)?
|
||||
$parameter:
|
||||
"$parameter=".($encode?urlencode($value):$value)
|
||||
);
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue