Re: extending a class?

From: Date: Tue, 26 Feb 2002 11:38:20 +0000
Subject: Re: extending a class?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-86226@lists.php.net to get a copy of this message
Hi Instead of extending the class you can create a language object inside 'form' class and refer it for all your stuffs regardless of language. class form { function form($lang) { if($lang == "dk") { $this->lang = new dk(); } else if ($lang == "en") { $this->lang = new en(); } } .... do what ever language stuff with $form->lang->somefunc(); Is it Ok...? On Tue, 26 Feb 2002, Nick Wilson wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi all > Is it possible to extend a class based on a value passed to the > constructor? > > Here's the scenario: I'm going to build a class to help me knock out > contanct forms for clients and I want to be able to run certain routines > with either Danish or English msg's. So I was thinking: > > $form=new form('dk') > > Would extend the class to include all the dk language routines and > > $form=new form('en') > > Would do likewise for english. > > Do you see what I mean? > > > Many thanks..... > - -- > - ----------------------------------------------------------- > www.explodingnet.com | Projects, Forums and > + Articles for website owners > - -- Nick Wilson -- | and designers. > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.0.6 (GNU/Linux) > > iD8DBQE8e252HpvrrTa6L5oRAnKFAJ9+bWkCFst5Y1YB/y0E8bbgqMnUUgCfVwQN > +IB7iaz5lgzE7EkE/OfqmqE= > =kfok > -----END PGP SIGNATURE----- > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > <smk_bk@yahoo.com> ------------------------------------------------------------------- We must use time wisely and forever realize that the time is always ripe to do right." -- Nelson Mandela -------------------------------------------------------------------

« previous php.general (#86226) next »