setlocale() function in PHP


The setlocale() method is used to set locale information.

Syntax

setlocale(constant, loc)

Parameters

  • constant − It specifies the locale information that should be set.

  • The following are the available constants −

    • LC_ALL  − All of the below

    • LC_COLLATE  − Sort order

    • LC_CTYPE  − Character classification and conversion

    • LC_MESSAGES  − System message formatting

    • LC_MONETARY  − Monetary/currency formatting

    • LC_NUMERIC  − Numeric formatting

    • LC_TIME  − Date and time formatting

  • loc  − It contains the information of country or region. If the location is "0", then the location setting is not affected and only the current setting is returned.

Return

The setlocale() function returns the current locale settings. It returns FALSE on failure.

Example

The following is an example −

 Live Demo

<?php
echo setlocale(LC_ALL,NULL);
?>

Output

en_US.UTF-8

Updated on: 24-Jun-2020

42 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements