Get a parameter specified by the given index
The function will return null if the key is not available
By default we will cast the return value into a string, if you want
something else specify it by passing the wanted type.
public getParameter ( mixed $index, string $type = 'string', mixed $defaultValue = null ) : mixed | ||
$index | mixed | The index of the parameter. |
$type | string | The return type, possible values are: bool, boolean, int, integer, float, double, string, array. |
$defaultValue | mixed | The value that should be returned if the key is not available. |
Résultat | mixed |
/** * Get the id of an item by the full URL of the current page. * Selects the proper part of the full URL to get the item's id from the database. * * @param FrontendURL $url * * @return int */ public static function getIdForTags(FrontendURL $url) { $itemURL = (string) $url->getParameter(1); return self::get($itemURL); }
/** * Get the id of an item by the full URL of the current page. * Selects the proper part of the full URL to get the item's id from the database. * * @param FrontendURL $URL The current URL. * @return int */ public static function getIdForTags(FrontendURL $URL) { // select the proper part of the full URL $itemURL = (string) $URL->getParameter(1); // return the item return self::get($itemURL); }