Re: Help with classes (oop)

From: Date: Mon, 03 Feb 2003 19:48:53 +0000
Subject: Re: Help with classes (oop)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-134169@lists.php.net to get a copy of this message
the function with the same name as the class is the constructor and is called when the instance is created. So "$first = new first" runs first::first() without passing any parameters hence the warning. Tim Ward http://www.chessish.com mailto:timward@chessish.com ----- Original Message ----- From: Chris Hayes <chayes@antenna.nl> To: <php-general@lists.php.net> 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. > > ><? php; > >class first > >{ > > var $age; > > var $name; > > > > function first($age, $name) > > { > > return $age.$name; > > } > >} > > > >//main script > >$first = new first; > >$test=$first->first(35, "chris"); > > > >print $test; > ?> > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#134169) next »