PHP 8.5.10 Released!

Yaf_Request_Abstract::getLanguage

(Yaf >=1.0.0)

Yaf_Request_Abstract::getLanguageRetrieve the client's preferred language

Description

public function Yaf_Request_Abstract::getLanguage(): ?string

Retrieve the client's preferred language

Parameters

This function has no parameters.

Return Values

The preferred language string, or null if it cannot be determined.

Examples

Example #1 Yaf_Request_Abstract::getLanguage() example

<?php
class IndexController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        // Assuming the client sends "Accept-Language: zh-CN"
        $language = $this->getRequest()->getLanguage();

        var_dump($language);
    }
}
?>

The above example will output something similar to:

string(5) "zh-CN"

See Also

add a note

User Contributed Notes

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