Re: [PHP] Help with classes (oop)

2003-02-03 Thread Maxim Maletsky
When you name a function in the class with the same name as the class itself, this function gets automatically executed upon defining the object (class). this is called `constructor'. in your very case, this is the function first, which requires two parameters to be passed to it. You need to crea

RE: [PHP] Help with classes (oop)

2003-02-03 Thread Leonard Burton
his->age; $retval .= $this->name; return $retval; } } -Original Message- From: Johannes Schlueter [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 2:59 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Help with classes (oop) On Monday 03 February 2

Re: [PHP] Help with classes (oop)

2003-02-03 Thread Chris Boget
> > 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; >

Re: [PHP] Help with classes (oop)

2003-02-03 Thread Johannes Schlueter
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;

[PHP] Re:[PHP] Help with classes (oop)

2003-02-03 Thread Daniel Leighton
Hi Leonard, Try this: total = $age.$name; } } //main script $obj = new first(35, "chris"); print $obj->total; ?> The problem with what you were doing is that when you were instantiating the class, with the way you have set this up, you need to pass arguments because when you create

Re: [PHP] Help with classes (oop)

2003-02-03 Thread Tim Ward
- From: Chris Hayes <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, February 03, 2003 7:35 PM Subject: Re: [PHP] Help with classes (oop) > Apparently it does not like the function name to be the same as the class > name. So change one of them. > > > &

Re: [PHP] Help with classes (oop)

2003-02-03 Thread Chris Boget
> Apparently it does not like the function name to be the same as the class > name. So change one of them. No, what's happening is that when you instantiate an class, it runs (as a constructor) the function whose name is the same as the class. So when you do this: $first = new first; it's auto

Re: [PHP] Help with classes (oop)

2003-02-03 Thread Chris Hayes
Apparently it does not like the function name to be the same as the class name. So change one of them. first(35, "chris"); print $test; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Help with classes (oop)

2003-02-03 Thread Leonard Burton
Greetings, I am trying to figure out using classes. I have read and read and read about them but still cannot figure them new fangled things out. Could someone please alter this snippet just a bit so it would be a correct test script with a call to it? When I run the script I get this