<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Perplexed Labs &#187; __call</title>
	<atom:link href="http://blog.perplexedlabs.com/tag/__call/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.perplexedlabs.com</link>
	<description>web development war stories from the frontlines to the backend</description>
	<lastBuildDate>Mon, 16 May 2011 14:19:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>PHP Daisy Chain Class Method Calls</title>
		<link>http://blog.perplexedlabs.com/2008/04/09/php-daisy-chain-class-method-calls/</link>
		<comments>http://blog.perplexedlabs.com/2008/04/09/php-daisy-chain-class-method-calls/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 21:25:26 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[self]]></category>
		<category><![CDATA[__call]]></category>

		<guid isPermaLink="false">http://www.perplexedlabs.com/2008/04/09/php-daisy-chain-class-method-calls/</guid>
		<description><![CDATA[The code snippet below shows an interesting technique to daisy chain calls to a particular method without having to implicitly call the parent::method() in the child method. It takes advantage of php's __call and self &#60;?php class b extends a { public function _init() { echo 'hello from b::_init&#60;br&#62;'; } } class a { public [...]


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/' rel='bookmark' title='Permanent Link: PHP Named Parameters'>PHP Named Parameters</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/02/04/php-simple-profiling-class/' rel='bookmark' title='Permanent Link: PHP Simple Profiling Class'>PHP Simple Profiling Class</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/12/17/php-parallel-web-scraper/' rel='bookmark' title='Permanent Link: PHP Parallel Web Scraper'>PHP Parallel Web Scraper</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The code snippet below shows an interesting technique to daisy chain calls to a particular method without having to implicitly call the <em>parent::method()</em> in the child method.  It takes advantage of php's <strong>__call</strong> and <strong>self </strong></p>
<pre class="brush: php; title: ;">
&lt;?php

class b extends a
{
	public function _init()
	{
		echo 'hello from b::_init&lt;br&gt;';
	}
}

class a
{
	public function _init()
	{
		echo 'hello from a::_init&lt;br';
	}

	public function __call($n, $a)
	{
		echo 'hello from a::__call&lt;br&gt;';
		call_user_func_array(array($this, '_'.$n), $a);
		call_user_func_array(array(self, '_'.$n), $a);
	}
}

$obj = new b;
$obj-&gt;init();

?&gt;
</pre>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/' rel='bookmark' title='Permanent Link: PHP Named Parameters'>PHP Named Parameters</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/02/04/php-simple-profiling-class/' rel='bookmark' title='Permanent Link: PHP Simple Profiling Class'>PHP Simple Profiling Class</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/12/17/php-parallel-web-scraper/' rel='bookmark' title='Permanent Link: PHP Parallel Web Scraper'>PHP Parallel Web Scraper</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2008/04/09/php-daisy-chain-class-method-calls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

