PHP 8.6.0 Beta 2 available for testing

Yaf_Request_Abstract::getPost

(Yaf >=3.2.2)

Yaf_Request_Abstract::getPostFetch a POST parameter

Описание

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

Retrieves a variable from $_POST.

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

name

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

default

The value to return if the variable is not found.

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

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

Примеры

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

<?php
class LoginController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        // Assuming the form was submitted with POST /login
        if ($this->getRequest()->isPost()) {
            $username = $this->getRequest()->getPost("username");
            $remember = $this->getRequest()->getPost("remember", "no");

            var_dump($username, $remember);
        }
    }
}
?>

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

string(8) "laruence"
string(3) "yes"

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

Добавить

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

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