On 3 June 2013 20:37, shiplu <[email protected]> wrote:
> Show a short reproducible code.
>
Short-ish ...
<?php
abstract class baseClass {
static public function generateLocalisedContent($s_Stuff){
throw new Exception('Must implement static public function ' .
get_called_class() . '::generateLocalisedContent().');
}
public function __construct($s_Stuff){
echo static::generateLocalisedContent($s_Stuff);
}
}
class sub1 extends baseClass{}
class sub2 extends baseClass{
static public function generateLocalisedContent($s_Stuff){
return 'Your stuff is ' . $s_Stuff . PHP_EOL;
}
}
try {
$o1 = new sub1('Stuffed1');
}
catch(Exception $ex){
echo $ex->getMessage(), PHP_EOL;
}
try {
$o2 = new sub2('Stuffed2');
}
catch(Exception $ex){
echo $ex->getMessage(), PHP_EOL;
}
?>
And I can now see an interface is a much simpler mechanism!
--
Richard Quadling
Twitter : @RQuadling
EE : http://e-e.com/M_248814.html
Zend : http://bit.ly/9O8vFY