开发者

What does "%sUser" and "%d" mean in this code?

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['USE开发者_JAVA技巧RNAME'];
        $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"


%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

http://us3.php.net/manual/en/function.sprintf.php


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜