Problems with classes
Posted: Sun Nov 06, 2005 2:15 am
Here is my class, it's very simple as I just want to try and get used to classes and using them:
in my php I use
to create a new User object.
I then have code like this:
But this echos out
Object id #1password.
How come? Why not test? If I don't include the line with $currentUser->password = "test"; and just echo out the password I still get: Object id #1password. Why? Why not "not_set"? Also why does it display Object id #1?
Code: Select all
<?php
class User
{
// Local variables
var $username;
var $password;
var $keepLoggedIn;
// Constructor function
function User()
{
$this->username = "not_set";
$this->password = "not_set";
$this->keepLoggedIn = "not_set";
}
}
?>Code: Select all
$currentUser = new User;I then have code like this:
Code: Select all
$currentUser->password = "test";
echo $currentUser.password . "<br>";Object id #1password.
How come? Why not test? If I don't include the line with $currentUser->password = "test"; and just echo out the password I still get: Object id #1password. Why? Why not "not_set"? Also why does it display Object id #1?