Re: About PHP Implements
| From: | Nathan Nobbe | Date: | Wed, 19 Dec 2007 00:10:58 +0000 |
| Subject: | Re: About PHP Implements | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-266052@lists.php.net to get a copy of this message | ||
On Dec 18, 2007 5:45 PM, Chris <dmagick@gmail.com> wrote:
> Jim Webber wrote:
> > Hello I have a PHP4 server and I'm trying to figure out how to do
> > "implements" on classes. Is there an analogous way to do this without
> > PHP5 installed?
>
> If you're using inheritance and child classes you could do it in a way,
> eg:
>
> class parent_class
> {
> function x()
> {
> echo 'You need to override this fn in your child class';
> }
> }
>
except that you have to waste usage of the extends keyword just to
'implement' parent_class. you can only implement one interface in this way.
there is no way to reasonably emulate the interface construct in php4.
in c++ you can emulate the interface construct by having a class that is
entirely virtual, but too bad; php4 doesnt have abstract classes either.
i recommend an upgrade to php5.
-nathan