Just wondering. I am trying to fiddle with classes. I declare it, i set the variables but i think the problem comes when i try to retrieve the attributes.
It always outputs the wrong variable even when i use the correct name see this:
<?php
class Member {
var $username;
var $age;
function create($uname, $a) {
$this->$username=$uname;
$this->$age=$a;
}
function show() {
echo $this->$username;
echo $this->$age;
}
}
?>
<h1> class is done </h1>
<h2> set it now </h2>
<?php
$new_member = new Member;
$new_member->create("gary", "2");
$new_member->show();
?>
So you see, instead of printing out "gary 2" it prints out "2 2". Any ideas why?
Thanks.