Re: Seemingly incorrect strict standard.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3 June 2013 20:37, shiplu <shiplu.net@xxxxxxxxx> 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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux