Home » PHP nl_langinfo() Function

PHP nl_langinfo() Function

by Online Tutorials Library

PHP String nl_langinfo() Function

The nl_langinfo() function is in-built function of PHP. It is used to access the individual elements of the locale categories. This function allows us to select any element specifically. Unlike the localeconv() function which returns all the local formatting information, nl_langinfo() function returns the specific information.

Note: One important thing to notice about nl_langinfo() function is that – this function is not implemented on the Windows platform.

Syntax

The basic syntax of nl_langinfo() function of PHP is:

Parameter

This function has only one parameter, i.e.,

item (mandatory) – item is the only parameter of nl_langinfo() function which may be an integer type value of the element or a constant name of the element. There is a list of the following nl_langinfo constants with their description for the item that may be used in this function with the item parameter. Some of these constants may not be defined or do not hold any value for certain locales.

Constant Description
LC_TIME Category Constant
ABDAY_(1-7) Abbreviated name of all the days (nth days) of the week
DAY_(1-7) Name of all the days of the week
ABMON_(1-12) Abbreviated name of all the months of the year
MON_(1-12) Name of all the months of the week
AM_STR String for Ante meridian
PM_STR String for Post meridian
D_T_FMT String which can be used to represent time and date as the format string for strftime() function
D_FMT String which can be used to represent the date as the format string for strftime() function
T_FMT String which can be used to represent time as the format string for strftime() function
T_FMT_AMPN String which can be used to represent the time in 12-hour format with ante/post meridian as a format string for strftime() function
ERA Alternate era.
ERA_YEAR Alternate era format of year
ERA_D_T_FMT Alternate era format of date and time
ERA_D_FMT Alternate era format of the date
ERA_T_FMT Alternate era format of time
LC_MONETARY Category Constant
INT_CURR_SYMBOL International currency symbol, e.g., USD
CURRENCY_SYMBOL Local currency symbol, e.g., $
CRNCYSTR Same value as CURRENCY_SYMBOL
MON_DECIMAL_POINT It is a monetary decimal point character
MON_THOUSAND_SEP Monetary thousands separator (three digits’ group)
MON_GROUPING Like “grouping” element
POSITIVE_SIGN +ive sign for positive values
NEGATIVE_SIGN -ive sign for negative values
INT_FRAC_DIGITS International fractional digits
FRAC_DIGITS Local fractional digits
P_CS_PRECEDES Returns TRUE (1) if CURRENCY_SYMBOL precedes a positive value and FALSE (0) if it is placed behind
P_SEP_BY_SPACE Returns TRUE (1) if there is a space between CURRENCY_SYMBOL and positive value.
N_CS_PRECEDES Returns TRUE (1) if CURRENCY_SYMBOL precedes a negative value and FALSE (0) if it is placed behind.
N_SEP_BY_SPACE Returns TRUE (1) if there is a space between CURRENCY_SYMBOL and a negative value.
P_SIGN_POSN
N_SIGN_POSN
  • Return 0 – Parentheses surround the quantity and CURRENCY_SYMBOL
  • Return 1 – Sign string is placed before the quantity and CURRENCY_SYMBOL
  • Return 2 – Sign string is placed after the quantity and CURRENCY_SYMBOL
  • Return 3 – If the sign string is placed immediately in front of CURRENCY_SYMBOL
  • Return 4 – Sign string immediately follows the CURRENCY_SYMBOL
LC_NUMERIC Category Constant
DECIMAL_POINT Decimal point character
RADIXCHAR Same value as DECIMAT_POINT
THOUSAND_SEP Separator character for thousands (Group of three digits)
THOUSEP Same value as THOUSAND_SEP
GROUPING
LC_MESSAGES Category Constant
YESEXPR Regex string for matching “YES” input.
NOEXPR Regex string for matching “NO” input.
YESSTR Output string for “YES.”
NOSTR Output string for “NO.”
LC_CTYPE Category Constant
CODESET It returns a string with the name of the character encoding.

Value return by nl_langinfo() function

It returns the element as a string on success or returns FALSE if the item is invalid.

You may also like