This is a newbie question.
I have created a class to handle user accounts. The code (as far as I have got) is shown below.
<?
class User{
private $title;
private $firstName;
private $initials;
private $surname;
private $userName;
private $pwd;
private $accountStatus;
private $securityLevel;
public function setUserName ($newUserName){
%this->userName = $newUserName;
}
public function getUserName (){
return $this->userName;
}
public function __construct($newUserName) {
$this->$setUserName = $newUserName;
}
public function validatePassword ($checkPassword){
if ($checkPassword == $this->pwd) {
return true;
}
else
{
return false;
}
}
public function updateUserDetails (){
}
public function suspendUserAccount(){
$this->accountStatus="S";
$this->updateUserDetails();
}
public function reinstateUserAccount(){
$this->accountStatus="A";
$this->updateUserDetails();
}
public function deactivateUserAccount(){
$this->accountStatus="D";
$this->updateUserDetails();
}
}
?>
My test class throws no errors, yet does nothing. What am I doing wrong? The faults clearly must lie in the User class.
The test class code is as follows :
<?
/*PHP Test Page to test the classes*/
include "User.php";
$newUser = new User("BEX");
echo "<br>";
echo $newUser->getUserName;
echo "Hello World";
?>
I get no output whatsoever!! If I comment out the lines that instantiate the User class, and call the getUserName method then I get "Hello World" in the browser.
I have created a class to handle user accounts. The code (as far as I have got) is shown below.
<?
class User{
private $title;
private $firstName;
private $initials;
private $surname;
private $userName;
private $pwd;
private $accountStatus;
private $securityLevel;
public function setUserName ($newUserName){
%this->userName = $newUserName;
}
public function getUserName (){
return $this->userName;
}
public function __construct($newUserName) {
$this->$setUserName = $newUserName;
}
public function validatePassword ($checkPassword){
if ($checkPassword == $this->pwd) {
return true;
}
else
{
return false;
}
}
public function updateUserDetails (){
}
public function suspendUserAccount(){
$this->accountStatus="S";
$this->updateUserDetails();
}
public function reinstateUserAccount(){
$this->accountStatus="A";
$this->updateUserDetails();
}
public function deactivateUserAccount(){
$this->accountStatus="D";
$this->updateUserDetails();
}
}
?>
My test class throws no errors, yet does nothing. What am I doing wrong? The faults clearly must lie in the User class.
The test class code is as follows :
<?
/*PHP Test Page to test the classes*/
include "User.php";
$newUser = new User("BEX");
echo "<br>";
echo $newUser->getUserName;
echo "Hello World";
?>
I get no output whatsoever!! If I comment out the lines that instantiate the User class, and call the getUserName method then I get "Hello World" in the browser.