Reputation: 468
i have problem could not be converted to string...
Catchable fatal error: Object of class User could not be converted to string in /home/mysite/example.com/directory/lang/lang.english.php on line 74
but i think error in userclass.php:
class User {
var $userid;
var $username;
var $pwd;
var $emailaddr;
var $icon;
var $usertype;
var $lang;
var $createdate;
var $loggedIn;
var $dflths;
var $dfltas;
var $auto;
function User() {
$this->userid = "";
$this->username = "";
$this->pwd = "";
$this->emailaddr = "";
$this->icon = "";
$this->usertype = "0";
$this->createdate = "";
$this->lang = "english";
$this->loggedIn = FALSE;
$this->dflths = 0;
$this->dfltas = 0;
$this->auto = "N";
}
}
Upvotes: 1
Views: 3756
Reputation: 141877
Something is attempting to convert your User to a string, but it doesn't have a __toString
.
This may be what you want to add to your user class:
public function __toString() {
return $this->username;
}
Also your constructor should be called __construct
not User
and you should not use the var
keyword. Those things come from really old (something like 15 years ago) versions of PHP.
I would recommended replacing var
with protected
if you use getters and setters. If not, then use public
to avoid breaking other code.
Upvotes: 2