Jochem Maas wrote:
Olivier Doucet schreef:
Hi Jochem,

2/ (or/and) Raise a warning or an error if a non static function is
as a static one
develop with error_reporting set to E_ALL | E_STRICT, then you'll get a big
warning about it

Yes, that's what I'm using right now. Although, that's not the highlighted

if your not gettting a 'Strict Warning' when calling a non-static method 
then error_reporting doesn't include E_STRICT. I tested this with your example 
code on
the cmdline to make sure.


the pragmatic solution is to not call non-static functions using
static syntax.

Well, this is the answer I didn't want :)

I here that alot :-)

Thank you for your feedback !


poor internal developers, they do have a tough job

the message is pretty clear:
"Strict Standards: Non-static method MyTest::myfunc() should not be called statically, assuming $this from incompatible context in.."

but the functionality is pretty weird, took me a while to get my head around.. until i came up with the scenario:
"what if this 'error' halted the compiler and threw a proper error"
then I imagined the massive outcry from the developers of millions of poorly coded scripts

then I remembered php 4 and ran this:


class MyTest {
    function myfunc() {
        echo get_class($this);

class MySecondTest {
    function test() {

$test = new MySecondTest();
$test->test(); //output: "MySecondTest"

and it all became clear

mental though, part of me wishes they'd forked php at 4 to save all the lame syntax and weirdness.

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to