I see similar questions asked but I seem to have problem with more basic stuff than were asked. How to declare a variable in php? My specific problem is I have a function that reads a DB table and returns the record (only one) as an object.
class User{
public $uid;
public $name;
public $status;
}
function GetUserInfo($uid)
{
// Query DB
$userObj = new User();
// convert the result into the User object.
var_dump($userObj);
return $userObj;
}
// In another file I call the above function.
....
$newuser = GetUserInfo($uid);
var_dump($newuser);
What is the problem here, I cannot understand. Essentially the var_dump()
in the function GetUserInfo()
works fine. The var_dump()
outside after the call to GetUserInfo()
does not work.
Thanks for any help.
- S