Re: [PHP] Seemingly incorrect strict standard.

[email protected] (Richard Quadling)
Newsgroups php.general
Message-ID <CAKUjMCXqGMqRKNP7rFZSbtzHOGneG+oU-65=UqRoh0W0FWh7kg@mail.gmail.com>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.