note 61506 deleted from language.oop5.patterns by felipe

From: Date: Sat, 15 Dec 2007 01:45:47 +0000
Subject: note 61506 deleted from language.oop5.patterns by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133510@lists.php.net to get a copy of this message
Note Submitter: jphp at dsf dot org dot uk ---- Aya: Yes, the example as it stands is pretty useless, and a static method achieves the same result much more easily. But with a more complicated system, say you have two different ways of doing "bark": <?php class Example1 { // singleton implementation boilerplate goes here public function bark() { echo "Woof"; } } class Example2 { // singleton implementation boilerplate goes here public function bark() { echo "Yap"; } } if (/* some condition */) $method = Example1::singleton(); else $method = Example2::singleton(); for ($i = 0; $i < 10; $i++) $method->bark(); ?>

« previous php.notes (#133510) next »