src/Routes/UrlManager.php
public function createUrl($params, $app = null)
    {
        $params = (array)$params;
        $anchor = isset($params['#']) ? '#' . $params['#'] : '';
        unset($params['#']);

        $route = rtrim($params[0], '/');
        unset($params[0]);
        $route = $this->buildRoutePath($route, $params);

        $baseUrl = $this->getBaseUrl($app);

        if ($this->suffix !== null) {
            $route .= $this->suffix;
        }
        if (!empty($params) && ($query = http_build_query($params)) !== '') {
            $route .= '?' . $query;
        }

        $route = ltrim($route, '/');
        return "$baseUrl/{$route}{$anchor}";
    }
public function createUrl($params, $app = null)
    {
        $params = (array)$params;
        $anchor = isset($params['#']) ? '#' . $params['#'] : '';
        unset($params['#']);

        $route = rtrim($params[0], '/');
        unset($params[0]);
        $route = $this->buildRoutePath($route, $params);

        $baseUrl = $this->getBaseUrl($app);

        if ($this->suffix !== null) {
            $route .= $this->suffix;
        }
        if (!empty($params) && ($query = http_build_query($params)) !== '') {
            $route .= '?' . $query;
        }

        $route = ltrim($route, '/');
        return "$baseUrl/{$route}{$anchor}";
    }
Creates a URL using the given route and query parameters.

You may specify the route as a string, e.g., `site/index`. You may also use an array
if you want to specify additional query parameters for the URL being created. The
array format must be:

```php
// generates: /site/index?param1=value1&param2=value2
['site/index', 'param1' => 'value1', 'param2' => 'value2']
```

If you want to create a URL with an anchor, you can use the array format with a `#` parameter.
For example,

```php
// generates: /site/index?param1=value1#name
['site/index', 'param1' => 'value1', '#' => 'name']
```

If you want to create a URL and such route is defined in any controller, for example '/site/view/{userName:\w+}',

```php
// generates: /site/view/admin
['site/view', 'userName' => 'admin']

// generates: /site/view/admin?param1=value
['site/view', 'userName' => 'admin', 'param1' => 'value1']
```

The URL created is a relative one. Use [[createAbsoluteUrl()]] to create an absolute URL.

Note that unlike [[\Reaction\Helpers\Url::toRoute()]], this method always treats the given route
as an absolute route.

@param string|array             $params use a string to represent a route (e.g. `site/index`),
or an array to represent a route with query parameters (e.g. `['site/index', 'param1' => 'value1']`).
@param RequestApplicationInterface|null $app
@return string the created URL