Re: Classes Constructor syntax

From: Date: Wed, 17 Jul 2002 16:40:47 +0000
Subject: Re: Classes Constructor syntax
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-108116@lists.php.net to get a copy of this message
On Wed, Jul 17, 2002 at 03:26:15PM +0200, David Russell wrote: > > class issue { > function issue() { //default constructor > } > function issue($number) { //1 variable constructor > } > } > > My question is: will this work? does PHP OOP support more than one > constructor? No. But, here's a workaround: class issue { function issue($number=NULL) { if ( is_null($number) ) { echo 'doing the first function'; } else { $this->issue1($number); } } function issue1($number) { echo 'in the second function'; } } # To call first function only... $Obj = new issue(); echo '<hr />'; # To call second function... $Obj = new issue('blue'); Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

« previous php.general (#108116) next »