所以我有这门课:
class c_user
{
function __construct($userID)
{
dbOpen($db); // open database
$sq = "select * from users where user_id='".$userID."'";
$rs = getRS($sq, $db); // query database - simplified
$this->firstname = $rs['firstname'];
}
}
我这样使用它:
$user = new c_user(123);
echo $user->firstname;
是否可以将数据作为关联数组访问?像那样:
echo $user['firstname'];
谢谢