Passing constructor values to functions in a class
| From: | Terence | Date: | Fri, 31 Oct 2003 03:38:47 +0000 |
| Subject: | Passing constructor values to functions in a class | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-168209@lists.php.net to get a copy of this message | ||
Dear List,
I've been struggling with this for some time now and can't for the life of
me figure out why the output is "GeorgeGeorge" and not "GeorgeBush"
<?php
class StaffDetails {
var $staff_name;
var $staff_surname;
function StaffDetails() {
$this->$staff_name="George";
$this->$staff_surname="Bush";
}
function StaffName() {
echo $this->$staff_name;
}
function StaffSurname() {
echo $this->$staff_surname;
}
}
$sd = new StaffDetails();
$sd->StaffName();
$sd->StaffSurname();
?>
References to links or tutorials most welcome :)
Thanks in advance.