Posted by Schmidty on 01/13/07 00:20
Fairly new to OOP and PHP5.
My question;
Maybe I am not thinking about this the right way? How do I reference a
variable or object(?) from one function to another in a class? Or how
do I pass the variable from one function or method to another? Am I
doing this right in the example below? How would I pass a variable from
one function to another?
Example ==========================================================
class NAME {
public $name;
public $unknown;
public $value;
function __construct($value) {
$this->setName($this->value);
}
function setName($value) {
$this->name = $value;
}
function getName() {
return $this->name;
}
function nameKid($unknown) {
$this->setName($unkown);
}
} // end class
$boy = new NAME("Joe");
$boy->getName();
Joe
END EXAMPLE ======================================================
Thanks,
Schmidty
Navigation:
[Reply to this message]
|