views:

39

answers:

2

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"

+3  A: 

%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

webdestroya
Thank you so much . give link that i can know about that pls
Masud
@Masud - http://us3.php.net/manual/en/function.sprintf.php
webdestroya
@Masud - Don't forget to mark your question as answered
webdestroya
A: 

%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.

efritz