Frontend\Core\Engine\Url::getParameter PHP Метод

getParameter() публичный Метод

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.
Результат mixed
    public function getParameter($index, $type = 'string', $defaultValue = null)
    {
        // does the index exists and isn't this parameter empty
        if ($this->hasParameter($index)) {
            return \SpoonFilter::getValue($this->parameters[$index], null, null, $type);
        }
        // fallback
        return $defaultValue;
    }

Usage Example

Пример #1
0
 /**
  * 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);
 }
All Usage Examples Of Frontend\Core\Engine\Url::getParameter