-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

* and then Simon Willison declared....
> Another different of doing the same kind of thing would be to use an 
> "object factory" as seen in the PEAR DB abstraction layer. This works by 
> having a static class method (i.e a method that can be called without 
> creating an instance of the class first) which returns a different 
> object depending on what arguments you use. Here is an example (it 
> expects FormEN and FormDK to have been defined as above):
> 
> class Form {
>    function getFormObject($language) {
>        if ($language == 'dk') {
>            return new FormDK;
>        } else {
>            return new FormEN;
>        }
> }
> 
> You can now create you object with the following code:
> 
> $form = Form::getFormObject('en');
> or
> $form = Form::getFormObject('dk');

Yep, I'll give that a go. That seems to be a nice clean way to do it and
I understand it a little better than your first example. :: is a
construct I've not used in php before. I know of Pear and have seen the
:: jobbie before but thought it unique to Pear and not available to
mear mortals. 

Thanks very much...
- -- 
- -----------------------------------------------------------
 www.explodingnet.com   |    Projects, Forums and
                        +    Articles for website owners 
- -- Nick Wilson --     |    and designers.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE8e3ryHpvrrTa6L5oRAt7aAJ9HquqJx/hRTfJUUyuwVWOb9lG3RgCfU2ZF
4O+mJugGsM95XhoUj6Tc0PY=
=2X43
-----END PGP SIGNATURE-----

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to