PHP 8.6.0 Beta 2 available for testing

Yaf_Request_Abstract::getQuery

(Yaf >=3.2.2)

Yaf_Request_Abstract::getQueryFetch a query parameter

Описание

public function Yaf_Request_Abstract::getQuery(string $name = ?, mixed $default = ?): mixed

Retrieves a variable from $_GET.

Список параметров

name

The variable name. If omitted, the whole array is returned.

default

The value to return if the variable is not found.

Возвращаемые значения

The query parameter value, or default if it is not set.

Примеры

Пример #1 Yaf_Request_Abstract::getQuery() example

<?php
class SearchController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        // Assuming the request is /search?keyword=yaf&page=2
        $keyword = $this->getRequest()->getQuery("keyword");
        $page    = (int) $this->getRequest()->getQuery("page", 1);

        var_dump($keyword, $page);
    }
}
?>

Вывод приведённого примера будет похож на:

string(3) "yaf"
int(2)

Смотрите также

Добавить

Примечания пользователей

Пользователи ещё не добавляли примечания для страницы
To Top