Yaf_Request_Abstract::isOptions
PHP Manual
PHP Manual»Yaf_Request_Abstract»Yaf_Request_Abstract::isOptions

Yaf_Request_Abstract::isOptions

(Yaf >=1.0.0)

Yaf_Request_Abstract::isOptions — Determine if the request is a OPTIONS request

Açıklama

public function Yaf_Request_Abstract::isOptions(): bool

Checks whether the request was sent with the OPTIONS method.

Bağımsız Değişkenler

Bu işlevin bağımsız değişkeni yoktur.

Dönen Değerler

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

Örnekler

Örnek 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;
        }
    }
}
?>

Ayrıca Bakınız

To Top