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.

ConstantDescription
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_STRString for Ante meridian
PM_STRString for Post meridian
D_T_FMTString which can be used to represent time and date as the format string for strftime() function
D_FMTString which can be used to represent the date as the format string for strftime() function
T_FMTString which can be used to represent time as the format string for strftime() function
T_FMT_AMPNString which can be used to represent the time in 12-hour format with ante/post meridian as a format string for strftime() function
ERAAlternate era.
ERA_YEARAlternate era format of year
ERA_D_T_FMTAlternate era format of date and time
ERA_D_FMTAlternate era format of the date
ERA_T_FMTAlternate era format of time
LC_MONETARY Category Constant
INT_CURR_SYMBOLInternational currency symbol, e.g., USD
CURRENCY_SYMBOLLocal currency symbol, e.g., $
CRNCYSTRSame value as CURRENCY_SYMBOL
MON_DECIMAL_POINTIt is a monetary decimal point character
MON_THOUSAND_SEPMonetary thousands separator (three digits' group)
MON_GROUPINGLike "grouping" element
POSITIVE_SIGN+ive sign for positive values
NEGATIVE_SIGN-ive sign for negative values
INT_FRAC_DIGITSInternational fractional digits
FRAC_DIGITSLocal fractional digits
P_CS_PRECEDESReturns TRUE (1) if CURRENCY_SYMBOL precedes a positive value and FALSE (0) if it is placed behind
P_SEP_BY_SPACEReturns TRUE (1) if there is a space between CURRENCY_SYMBOL and positive value.
N_CS_PRECEDESReturns TRUE (1) if CURRENCY_SYMBOL precedes a negative value and FALSE (0) if it is placed behind.
N_SEP_BY_SPACEReturns 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_POINTDecimal point character
RADIXCHARSame value as DECIMAT_POINT
THOUSAND_SEPSeparator character for thousands (Group of three digits)
THOUSEPSame value as THOUSAND_SEP
GROUPING
LC_MESSAGES Category Constant
YESEXPRRegex string for matching "YES" input.
NOEXPRRegex string for matching "NO" input.
YESSTROutput string for "YES."
NOSTROutput string for "NO."
LC_CTYPE Category Constant
CODESETIt 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.






Latest Courses