“%sUser”是什么意思和“%d”这段代码的意思是?

发布于 2024-09-16 14:30:48 字数 692 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朦胧时间 2024-09-23 14:30:48

%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 of DB_TBL_PREFIX

%d is a number, which is being replaced by the value of $uid

https://www.php.net/manual/en/function.sprintf.php

離殇 2024-09-23 14:30:48

%s%dsprintf 的字符串参数的类型说明符。在此处查看该函数的文档:https://www.php.net/sprintf

%s and %d are type specifiers for the string argument to sprintf. Check out the docs for the function here: https://www.php.net/sprintf.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文