This article describes how to use the sprintf () function in php. if you need it, refer to it. Sprintf function The sprintf () function writes formatted strings to a variable. Syntax sprintf (format, arg1, arg2, arg ++) Parameter description Format is required. Conversion format. Arg1 is required. Specifies the parameter inserted at the first % symbol in the format string. Optional. Specifies the parameter inserted at the second % symbol in the format string. Optional. Specifies the parameters inserted to the third, fourth, and other % symbols in the format string.Description The format parameter is the conversion format. it starts with the percent sign ("%") and ends with the conversion character. The following are possible format values: %-Return percent sign % B-binary number % c-following the ASCII value character % d-signed decimal number % e-resumable notation (such as 1.5e + 3) % u-unsigned decimal number % f-floating point number (local settings aware) % F-floating point number (not local settings aware) % o-octal digits % s-string % x-hexadecimal digits (lowercase letters) % X-hexadecimal digits (uppercase letters)Parameters such as arg1, arg2, ++ are inserted to the percent sign (%) in the main string. This function is executed step by step. In the first % symbol, insert arg1, at the second % symbol, insert arg2, and so on. Note: If the % symbol is greater than the arg parameter, you must use a placeholder. The placeholder is inserted after the % symbol, which consists of numbers and "\ $. Tip: Related functions: fprintf (), printf (), vfprintf (), vprintf (), and vsprintf (). The above content is taken from the php manual for your reference. |