The code is as follows
代码如下 |
复制代码 |
$query = sprintf('INSERT INTO %sUSER (USERNAME, PASSWORD, ' .
'EMAIL_ADDR, IS_ACTIVE, PERMISSION) VALUES ("%s", "%s", "%s", %d, %d)',
DB_TBL_PREFIX,
mysql_real_escape_string($this->username, $GLOBALS['DB']),
mysql_real_escape_string($this->password, $GLOBALS['DB']),
mysql_real_escape_string($this->emailAddr, $GLOBALS['DB']),
$this->isActive,
$this->permission);
|
|
Copy code
|
$query = sprintf('INSERT INTO %sUSER (USERNAME, PASSWORD, ' .
'EMAIL_ADDR, IS_ACTIVE, PERMISSION) VALUES ("%s", "%s", "%s", %d, %d)',
DB_TBL_PREFIX,
mysql_real_escape_string($this->username, $GLOBALS['DB']),
mysql_real_escape_string($this->password, $GLOBALS['DB']),
mysql_real_escape_string($this->emailAddr, $GLOBALS['DB']),
$this->isActive,
$this->permission);
代码如下 |
复制代码 |
PHP中echo,print,printf,sprintf的区别
$str='let/'s study php!'';
echo $str." ";
$number=print $str." ";
echo $number." ";
$format="%b%c%d";
$number1=printf($format,88,88,88);
echo " ".$number1;
echo " ".sprintf($format,88,88,88);
?>
|
Sprintf is used here to format the string. Is there any difference between this way of writing and the way of directly connecting them with string connectors? In other words, this is better
Be more rigorous
The syntax format of printf() function and sprintf() function is:
int printf(string $format[,mixed $arg1[,mixed args2...]])
String sprintf(string $format[,mixed $arg1[,mixed args2...]])
| A small example:
The difference between echo, print, printf and sprintf in PHP
$str='let/'s study php!'';
echo $str." ";
$number=print $str." ";
echo $number." ";
$format="%b%c%d";
$number1=printf($format,88,88,88);
echo " ".$number1;
echo " ".sprintf($format,88,88,88);
?>
Introduction to echo, print, printf, sprintf
The return value of print output mode is of type int, and the return value is always 1. The syntax format of print is as follows:
int print(string $str)
The echo output method has no return value. The syntax format of echo is as follows:
void echo(string $str[,string $str1...])
In PHP, echo and print are generally interchangeable, but in some cases there are differences between the two methods, as shown in:
1) echo supports multiple parameters, but print only supports one parameter
2) The return value of echo is void, and print has a return value that is always 1
http://www.bkjia.com/PHPjc/628935.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/628935.htmlTechArticleI heard from the teacher before that the sprintf() function needs to use the echo method to display the formatted string output. , let me look at the simple method below. I am reading some information, books...
|