Just playing around with classes.. I'm getting incredibly frustrated with this....
filename blah.php
<?php
class TestClass {
var $server;
var $username;
var $password;
function setServer($arg) { $this->$server = $arg; }
function setUsername($arg) { $this->$username = $arg; }
function setPassword($arg) { $this->$password = $arg; }
function getServer() { return $this->$server; }
function getUsername() { return $this->$username; }
function getPassword() { return $this->$password; }
}
$DB = new TestClass();
$DB->setServer("localhost");
$DB->setUsername("username");
$DB->setPassword("password");
echo("<br>Server: "); echo($DB->getServer());
echo("<br>User: "); echo($DB->getUsername());
echo("<br>Password: "); echo($DB->getPassword());
?>
has this output:
Server: password
User: password
Password: password
why the hell are all three variables getting the same value... oh, and if I do this:
$DB->setServer("localhost");
echo("<br>Server: "); echo($DB->getServer());
$DB->setUsername("username");
echo("<br>User: "); echo($DB->getUsername());
$DB->setPassword("password");
echo("<br>Password: "); echo($DB->getPassword());
it "looks" like it has worked properly (the correct values for the variables display)
is this a problem with my code? my setup? or what the hell!