“%sUser”是什么意思和“%d”这段代码的意思是?
PHP 函数:
public static function getById($uid)
{
$u = new User();
$query = sprintf('SELECT USERNAME, PASSWORD, EMAIL_ADDR, IS_ACTIVE ' .
'FROM %sUSER WHERE USER_ID = %d',
DB_TBL_PREFIX,
$uid);
$result = mysql_query($query, $GLOBALS['DB']);
if (mysql_num_rows($result))
{
$row = mysql_fetch_assoc($result);
$u->username = $row['USERNAME'];
$u->password = $row['PASSWORD'];
$u->emailAddr = $row['EMAIL_ADDR'];
$u->isActive = $row['IS_ACTIVE'];
$u->uid = $uid;
}
mysql_free_result($result);
return $u;
}
请帮助我,我无法理解这个“%sUser”和“%d”的含义
PHP function:
public static function getById($uid)
{
$u = new User();
$query = sprintf('SELECT USERNAME, PASSWORD, EMAIL_ADDR, IS_ACTIVE ' .
'FROM %sUSER WHERE USER_ID = %d',
DB_TBL_PREFIX,
$uid);
$result = mysql_query($query, $GLOBALS['DB']);
if (mysql_num_rows($result))
{
$row = mysql_fetch_assoc($result);
$u->username = $row['USERNAME'];
$u->password = $row['PASSWORD'];
$u->emailAddr = $row['EMAIL_ADDR'];
$u->isActive = $row['IS_ACTIVE'];
$u->uid = $uid;
}
mysql_free_result($result);
return $u;
}
Pls help me i can't understand what did mean by this "%sUser" and "%d"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
%s
是一个“字符串”,将被替换为DB_TBL_PREFIX
的值%d
是一个数字,将被替换为值$uid
https://www.php。 net/manual/en/function.sprintf.php
%s
is a "String" and is being replaced by the value ofDB_TBL_PREFIX
%d
is a number, which is being replaced by the value of$uid
https://www.php.net/manual/en/function.sprintf.php
%s
和%d
是sprintf
的字符串参数的类型说明符。在此处查看该函数的文档:https://www.php.net/sprintf。%s
and%d
are type specifiers for the string argument tosprintf
. Check out the docs for the function here: https://www.php.net/sprintf.