Re: Beginner Tutorials for using CLASSES in PHP4
| From: | Nathan Nobbe | Date: | Thu, 11 Oct 2007 02:51:53 +0000 |
| Subject: | Re: Beginner Tutorials for using CLASSES in PHP4 | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263083@lists.php.net to get a copy of this message | ||
On 10/10/07, Robert Cummings <robert@interjinn.com> wrote:
>
> On Wed, 2007-10-10 at 22:15 -0400, Nathan Nobbe wrote:
> > well i have to say i dont really see the difference between an
> > implicit and explicit interface.
> >
> > the example you gave looks like it works just like the example i gave.
> >
> > in your example the check for the function is performed at runtime.
> > in the example i gave the check for the interface is performed at
> > runtime.
>
> Interfaces are checked at parse time. I'm very sure you need to include
> the interface description before you can implement it. That makes it
> explicit. My example doesn't need any interface description, the
> interface of "wiggle()" is implicit.
>
> > the only difference is that in mine php does the check and in yours
> > method_exists()
> > does the check.
>
> I only put that there for fun. I could have skipped the check entirely.
> Then it would be expected that the wiggle() method existed. If the
> method doesn't exist then at run time the script will stop-- fortunately
> with a fatal error :)
i suppose the same could be done with the interface construct as well;
simply remove the type hinting with the name of the interface and the
call becomes implicit.
-nathan