PHP 8.6.0 Beta 2 available for testing

Yaf_Request_Abstract::getRequest

(Yaf >=3.2.2)

Yaf_Request_Abstract::getRequestFetch a REQUEST variable

Descrizione

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

Retrieves a variable from $_REQUEST.

Elenco dei parametri

name

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

default

The value to return if the variable is not found.

Valori restituiti

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

Esempi

Example #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);
    }
}
?>

Il precedente esempio visualizzerà qualcosa simile a:

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

Vedere anche:

add a note

User Contributed Notes

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