Gets a list of languages acceptable by the client browser.
public getLanguages ( ) : array | ||
return | array | Languages ordered in the user browser preferences |
$request = Request::createFromGlobals(); $languages = $request->getLanguages(); // $languages will be an array of strings representing the preferred languages of the user
use Symfony\Component\HttpFoundation\Request; function myFunction(Request $request) { $languages = $request->getLanguages(); // do something with the languages }In this example, we define a function that takes a Request object as its argument and calls the `getLanguages()` method to retrieve the user's preferred languages. The Symfony\Component\HttpFoundation\Request package library provides an object-oriented interface for handling HTTP requests and responses. The `getLanguages()` method is part of this package and is used to retrieve the user's preferred languages from the Accept-Language header.
public getLanguages ( ) : array | ||
return | array | Languages ordered in the user browser preferences |