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)

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top