RE: [PHP] Help with classes (oop)
| From: | Leonard Burton | Date: | Mon, 03 Feb 2003 20:06:44 +0000 |
| Subject: | RE: [PHP] Help with classes (oop) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-134176@lists.php.net to get a copy of this message | ||
Thanks for all the help thusfar. Classes are just not something I am
understanding. I have read the sections on classes in several books and the
www.php.net section on them and still am missing something. It seems that
these books have been telling me what a light switch is used for but not how
to use one.
So would I call the class like this?
$first = new first;
$first->setData(35, "chris");
$test=$first->returnData;
print $test;
Thanks again,
Leonard.
Just as a refresher here is the class.
class first
{
var $age;
var $name;
function first()
{
$age = 0;
$name = '';
}
function setData( $age, $name )
{
$this->age = $age;
$this->name = $name;
}
function returnData()
{
$retval = '';
$retval = $this->age;
$retval .= $this->name;
return $retval;
}
}
-----Original Message-----
From: Johannes Schlueter [mailto:php@schlueters.de]
Sent: Monday, February 03, 2003 2:59 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Help with classes (oop)
On Monday 03 February 2003 20:45, Chris Boget wrote:
> function setData( $age, $name )
> {
> $age = $age;
> $name = $name;
> }
Is useless ;-) I think you wanted this:
function setData( $age, $name )
{
$this->age = $age;
$this->name = $name;
}
johannes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php