For some strings, the input must be in a specific format. sprintf can be used for convenient processing, and no additional processing is required.
The usage of sprintf in Perl is as follows:
Sprintf format, list
For example:
$ Result =
$bookSQL =sprintf ("UPDATE book SET pass=%s WHERE id=%d",
Getsqlvaluestring ($_post[' list '], "text"),
Getsqlvaluestring ($_get[' id '], "int"));
Getsqlvaluestring This function can be replaced by other functions
But here's the function of
In the past, I heard from my teacher that the sprintf () function must use the echo method to display the formatted string and output. Let's take a look at the simple method.
I am reading some documents and always see the following code when reading
I am reading some documents and always see the following code when reading books: The code is as follows:Copy code $ Query = sprintf ('Insert INTO % sUSER (USERNAME, PASSWORD ,'.'Email _ ADDR, IS_ACTIVE, PERMISSION) VALUES ("% s", % d, % d )',DB_
This article mainly describes the PHP sprintf and printf function usage difference analysis, need friends can refer to the following Here's an example: rounding the two-bit code after the decimal point is as follows: explanation%0.2f
P study notes on PHP function sprintf () sprintf formatting strings. Syntax: stringsprintf (stringformat, mixed [args]...); return value: string type: data processing content description this function is used to format the string. The format
This article mainly analyzes the differences and usage between echo, print, printf, and sprintf functions in PHP. If you need some help, please refer to them.
This article mainly analyzes the differences and usage between echo, print, printf, and
P study notes on PHP function sprintf () sprintf formatting strings. Syntax: stringsprintf (stringformat, mixed [args]...); return value: string type: data processing content description this function is used to format the string. The format
Grammar
sprintf (format,arg1,arg2,arg++)
Parameters
Description
Format
Necessary. Conversion format.
Arg1
Necessary. Specifies the parameter that is inserted into the first% symbol in the format
This article introduces echo, print, print_r, printf, sprintf, and var_dump. For more information, see. 1. define echo and use the PHPecho () function to output one or more string methods.
This article introduces echo, print, print_r, printf,
Start
I used to think that stringstream is far inferior to sprintf.
Recently, it suddenly sprouted to see if stirngstream is really as bad as I thought.
Body
Let's take a look at the comparison.
// Stringstream.
Stringstream
Directory
Character and number conversion: sprintf and sscanf
Brief Introduction
Instance
Running result
Conversion of characters and numbers: sprintf and sscanf
Both sprintf and sscanf are functions in the stdio. h header file.
1.Print(Language structure)Pirnt-Output stringint print ( string $arg )Example:输出:Hello World!print("Hello World!");等价于:print "Hello World!";Attention:
Print is a language structure and can enclose the argument list without parentheses;
sprintf Use examples:
1, BCD converted to characters
char src = 0x3a;Char tmp[6];memset (TMP, 0x00, sizeof (TMP));sprintf (tmp, "%02x", SRC);
Description1 Print out TMP as 3A2)%02x Meaning:02:0 indicates that the length is less than 0 padding, 2
Recently in the content of remote upgrades, through practice to really realize the role of different copy functions
char*strcpy (char *dest, const char *SRC);
It operates on a string, completes a copy from the source string to the destination string,
Echo () function definition and usage
The echo () function outputs one or more strings.Syntax
echo(strings)
Parameters
Description
Strings
Required. One or more strings to be sent to the output.
Tips and
sprintfFormats the string.Syntax: string sprintf (string format, mixed [args] ...);return value: StringFunction type: Data processingContent DescriptionThis function is used to format a string. The parameter format is the converted form, starting
Document directory
Syntax
Description
Syntax
sprintf(format,arg1,arg2,arg++)
Parameters
Description
Format
Required. Conversion format.
Arg1
Required. Specifies the parameter inserted at the first % symbol
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.