PHP 8.6.0 Beta 2 available for testing

Yaf_Request_Abstract::getRequest

(Yaf >=3.2.2)

Yaf_Request_Abstract::getRequestFetch a REQUEST variable

Açıklama

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

Retrieves a variable from $_REQUEST.

Bağımsız Değişkenler

name

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

default

The value to return if the variable is not found.

Dönen Değerler

The $_REQUEST variable value, or default if it is not set.

Örnekler

Örnek 1 Yaf_Request_Abstract::getRequest() example

<?php
class SearchController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        // Assuming the request is /search?keyword=yaf
        $keyword = $this->getRequest()->getRequest("keyword");
        $source  = $this->getRequest()->getRequest("source", "web");

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

Yukarıdaki örnek şuna benzer bir çıktı üretir:

string(3) "yaf"
string(3) "web"

Ayrıca Bakınız

add a note

User Contributed Notes

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