Warning: Constant ABSPATH already defined, this will be an error in PHP 9 in /home/killerph/public_html/wp-config.php on line 19

Warning: Cannot modify header information - headers already sent by (output started at /home/killerph/public_html/wp-config.php:19) in /home/killerph/public_html/wp-includes/feed-rss2-comments.php on line 8
Comments on: PHP Interfaces: when and why you should use them instead of classes? https://www.killerphp.com/articles/php-interfaces/ Thu, 09 Dec 2021 20:55:16 +0000 hourly 1 https://wordpress.org/?v=6.4.15 By: Jay https://www.killerphp.com/articles/php-interfaces/#comment-280 Thu, 15 Nov 2007 05:40:04 +0000 http://www.killerphp.com/articles/php-interfaces/#comment-280 hi… i get the idea now how interfaces, but as a grasp, its more like an Abstract Class to me.

i would like to ask if PHP support object declaration inside an interface???

i could hardly find resources that discusses how to create interfaces, and this was my first step and thanks again… but if anyone might care to give me a site where i can find tutorials about interfaces or OO in PHP as a whole…

a whole lot of thanks.

God bless!

]]>
By: Stefan Mischook https://www.killerphp.com/articles/php-interfaces/#comment-279 Thu, 30 Aug 2007 23:23:20 +0000 http://www.killerphp.com/articles/php-interfaces/#comment-279 Hi Jim,

Fair enough.

I appreciate your input as it helps to provide more insight into the subject.

Thanks,

Stefan

]]>
By: Jim https://www.killerphp.com/articles/php-interfaces/#comment-278 Thu, 30 Aug 2007 22:14:58 +0000 http://www.killerphp.com/articles/php-interfaces/#comment-278 Hi, Great Podcast.

But I didn’t agree 100% with the way you described Interfaces. You described interfaces as being an alternative to abstract classs, kind of a more ‘abstract’ abstract class since you do not but in any guts at all. But I do not believe that is the point of an interface and you are really describing a very abstract base class. This was must illustrated by the animal example you gave. You define a class with methods that represent what an animal is and you leave the filling in of methods to classes that inherit form it like this.

Abstract Animal{
-abstract breath()
-abstract eat()
-abstract move()
}
Abstract Aquatic_Animal extends Animal{
-breath{ use_gills();}
-move{ move_fins();}
}
shark extends Aquatic_Animal {
-eat(){ bite(Animal $food);}
}
gold_fish extends Aquatic_Animal{
-eat(){swallow(Plant $food);}
}

Interfaces are more for giving general abilities to classes that aren’t logical parts of the class itself. Things of this nature would be ‘Draw’ class that would have a method called ‘draw()’ that returns a image of your animal. Or maybe an iterator interface that lets you treat your object like it is a set.

]]>
By: Stefan Mischook https://www.killerphp.com/articles/php-interfaces/#comment-277 Wed, 10 Jan 2007 15:20:50 +0000 http://www.killerphp.com/articles/php-interfaces/#comment-277 Hi Hugo,

I’ve updated it with the full podcast – it is now about 11 minutes.

Sorry about the confusion.

Stefan

]]>
By: Hugo https://www.killerphp.com/articles/php-interfaces/#comment-276 Wed, 10 Jan 2007 11:42:42 +0000 http://www.killerphp.com/articles/php-interfaces/#comment-276 Hi, your podcast seems to abruptly end mid sentence.
The downloaded file is 5 mins long. Is this correct?

Thanks, Hugo

]]>
By: Eric Gruber https://www.killerphp.com/articles/php-interfaces/#comment-275 Fri, 01 Sep 2006 11:46:44 +0000 http://www.killerphp.com/articles/php-interfaces/#comment-275 Well, I like Quicktime because I have a Mac, and because any movie you make in older versions of QT works with future ones.

Yes, I do find the videos interesting (as well as the mp3s). I really want to learn more about PHP and this is really helping out. Keep up the great work!

]]>
By: Stefan Mischook https://www.killerphp.com/articles/php-interfaces/#comment-274 Thu, 31 Aug 2006 21:00:53 +0000 http://www.killerphp.com/articles/php-interfaces/#comment-274 Hi,

Yes the videos are now embedded. I will look into format for downloading – do you have a preference?

That said, do you find the video interesting?

Thanks for the feedback.

Stefan

]]>
By: Eric Gruber https://www.killerphp.com/articles/php-interfaces/#comment-273 Thu, 31 Aug 2006 20:43:47 +0000 http://www.killerphp.com/articles/php-interfaces/#comment-273 Sorry, I wasn’t more clear.

I noticed the link, but a true podcast has a subscription feature (such as with iTunes or another podcast application) where one can download the actual file and then view it on their computer.

That’s what I meant. The videos are still embedded however and can’t be downloaded, correct?

]]>
By: Stefan Mischook https://www.killerphp.com/articles/php-interfaces/#comment-272 Thu, 31 Aug 2006 05:31:11 +0000 http://www.killerphp.com/articles/php-interfaces/#comment-272 Hi Eric,

At the beginning of this article you will notice a link to the mp3 file.

Thanks for the comments.

Stefan

]]>
By: Eric Gruber https://www.killerphp.com/articles/php-interfaces/#comment-271 Thu, 31 Aug 2006 03:53:52 +0000 http://www.killerphp.com/articles/php-interfaces/#comment-271 I like the site and find it informative. I just wish that you had a video/audio podcast instead of whatever embedded format you’re using so I didn’t have to be hooked up to a web browser/internet to partake.

I’m a take it and go kind of guy. 🙂

]]>