PHP 8.6.0 Beta 3 is available for testing

Yaf_Request_Abstract::isOptions

(Yaf >=1.0.0)

Yaf_Request_Abstract::isOptionsDetermine if the request is a OPTIONS request

Descrizione

public function Yaf_Request_Abstract::isOptions(): bool

Checks whether the request was sent with the OPTIONS method.

Elenco dei parametri

Questa funzione non contiene parametri.

Valori restituiti

Returns true if the request method is OPTIONS, false otherwise.

Esempi

Example #1 Yaf_Request_Abstract::isOptions() example

<?php
class ApiController extends Yaf_Controller_Abstract
{
    public function corsAction()
    {
        // Assuming the browser sends a CORS preflight request
        if ($this->getRequest()->isOptions()) {
            $this->getResponse()
                 ->setHeader("Allow", "GET, POST, OPTIONS")
                 ->setBody("");
            return false;
        }
    }
}
?>

Vedere anche:

add a note

User Contributed Notes

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