createUrl() public method
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:
// generates: /index.php?r=site%2Findex¶m1=value1¶m2=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,
// generates: /index.php?r=site%2Findex¶m1=value1#name ['site/index', 'param1' => 'value1', '#' => 'name']
The URL created is a relative one. Use createAbsoluteUrl() to create an absolute URL.
Note that unlike yii\helpers\Url::toRoute(), this method always treats the given route as an absolute route.
public string createUrl ( $params ) | ||
---|---|---|
$params | string|array |
Use a string to represent a route (e.g. |
return | string |
The created URL |
Please login to continue.