<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Wed, 22 May 2013 00:23:34 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Pixelstech.com: Should we use Abstract class or Interface?]]></title>
      <guid>http://www.phpdeveloper.org/news/19478</guid>
      <link>http://www.phpdeveloper.org/news/19478</link>
      <description><![CDATA[<p>
On the Pixelstech.com site today there's a new post that talks about the <a href="http://www.pixelstech.net/article/1366044255_Should_we_use_Abstract_class_or_Interface_">differences between abstract classes and interfaces</a> and when's the best time to use either (or both).
</p>
<blockquote>
When we write programs, we may often get into a situation where we don't know whether we should use Abstract class or Interface when we want to define an abstract object. These two are very similar and they are interchangeable. On Stackoverflow, this question is asked many times, it's related to many programming languages. Also in the official documentation of PHP regarding the Abstract class and Interface, people are arguing about this. To understand this question, we need to understand their differences and use scenarios.
</blockquote>
<p>
They provide examples of abstract class and interface usage with one of the main differences being that you can define functionality in abstract classes. There's also examples showing classes that extend the abstract class while implementing the interface at the same time, helping to define the object structure to an even finer level.
</p>
Link: http://www.pixelstech.net/article/1366044255_Should_we_use_Abstract_class_or_Interface_]]></description>
      <pubDate>Thu, 18 Apr 2013 09:22:23 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Johannes Schluter's Blog: Jason, let me help you!]]></title>
      <guid>http://www.phpdeveloper.org/news/14604</guid>
      <link>http://www.phpdeveloper.org/news/14604</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Johannes Schluter</i> looks at <A href="http://schlueters.de/blog/archives/135-Jason,-let-me-help-you!.html">a helpful new inclusion</a> into the latest versions of the PHP trunk - a new JSON serialization interface included in the core.
</p>
<blockquote>
For many PHP objects the JSON-representation of the data is a bit more complex.for instance what about private properties or maybe you want to calculate some inner values? - In PHP 5.3 you were on your own. but thanks to Sara there's hope in sight: the new interface JsonSerializable. Classes implementing this interface have to provide a method jsonSerialize()  which will be called by json_encode() and has to return a JSON-compatible representation of the data by doing whatever you want. 
</blockquote>
<p>
He gives two examples of this new feature in action - a simple one that just spits out some basic JSON as a result of the output of a class and the other that's a bit more technical, involving multiple class isntances, a stdClass and a normal array.
</p>]]></description>
      <pubDate>Fri, 04 Jun 2010 10:02:15 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP 10.0 Blog: duck operator]]></title>
      <guid>http://www.phpdeveloper.org/news/10352</guid>
      <link>http://www.phpdeveloper.org/news/10352</link>
      <description><![CDATA[<p>
In <a href="http://php100.wordpress.com/2008/06/05/duck-operator/">this new post</a> to the PHP 10.0 blog today, <i>Stas</i> talks about <a href="http://en.wikipedia.org/wiki/Duck_typing">duck typing</a>, a method that lets the code decide the functionality to use rather than a direct relation to a parent.
</p>
<blockquote>
Well, if you are into <a href="http://en.wikipedia.org/wiki/Duck_typing">duck typing</a> style of programming, it may be interesting for you to have an object that implements certain set of functions, but not necessary declares it at class definition. Languages like Smalltalk do it all day along, so why PHP couldn't?
</blockquote>
<p>
His example defines an interface Cow and a class MooingGrassEater and a function, CowConsumer, that does the work. A classname is passed in and an instance of that class is checked with "implements" rather than "instanceof" to see if it uses the Cow interface. He points out a place where PHP itself uses something similar in <a href="http://php.net/manual/en/function.stream-wrapper-register.php">user defined streams</a>.
</p>]]></description>
      <pubDate>Thu, 05 Jun 2008 14:36:31 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Michael Girouard's Blog: One Step Closer to an Abstract Singleton]]></title>
      <guid>http://www.phpdeveloper.org/news/9122</guid>
      <link>http://www.phpdeveloper.org/news/9122</link>
      <description><![CDATA[<p>
<i>Michael Girouard</i> has <a href="http://www.lovemikeg.com/blog/2007/11/24/one-step-closer-to-an-abstract-singleton/">pointed out</a> that things in the PHP world are one step closer to being able to create an abstract Singleton object via a simple script he's shared.
</p>
<blockquote>
<p>
The singleton is an incredibly useful pattern in PHP for many reasons. I tend to find myself using them when I know I should be using static classes, but can't because of PHP's lack of proper class name discovery in extended static classes. 
</p>
<p>
[...] And that works like a charm every time. The problem is, in one application there may be several classes that need to be singletons. In which case my first thought was to build an abstract singleton.
</p>
</blockquote>
<p>
Unfortunately, it didn't quite work like he'd thought it would. He did, however, come up with something that did work - creating an interface and making an abstract implementation of it (code example for this included). 
</p>]]></description>
      <pubDate>Tue, 27 Nov 2007 09:37:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[CodeSnipers.com: Embarking on PHP5 Objects]]></title>
      <guid>http://www.phpdeveloper.org/news/4680</guid>
      <link>http://www.phpdeveloper.org/news/4680</link>
      <description><![CDATA[From CodeSnipers.com today, there's a new post with their look at <a href="http://codesnipers.com/?q=node/218&title=">objects in PHP5</a> - how they work, how they're different from in PHP4, and some code to show their use.
<p>
<quote>
<i>
After a brief few weeks studying Perl and its nuances I'm going to take a look at PHP5 Objects. 
<p>
One of the annoying things with object in PHP 4 was you had to use a lot of references, you know, that funny & symbol. No longer needed in PHP 5 because you use "Object Handles" perhaps similar to a file handler you when fopen a file. Also available now are access modifiers "public/protected/package" and interface implementation. I can hear the beer mugs of java programmers being raised in celebration to this one. Also new to PHP 5 are real constructors and destroy methods. There are many more features, but lets see some code.
</i>
</quote>
<p>
There are <a href="http://codesnipers.com/?q=node/218&title=">code examples</a> that show some of the new keywords (private, public, etc) that the object structure uses, as well as how you can use them. They link to the PDF of <a href="http://www.phptr.com/content/images/013147149X/downloads/013147149X_book.pdf">Power PHP 5 Programming</a> for a good place to start...]]></description>
      <pubDate>Wed, 18 Jan 2006 06:40:42 -0600</pubDate>
    </item>
  </channel>
</rss>
