Hi,

at first, im really really sorry to bother the internals-list with this
problem (especially Derick for coming back from playing somewhere else
... (<[EMAIL PROTECTED]>) ), but i didnt find
an answer on php.general or german php mailinglist

if anybody just can point me to any discussions, websites, bugs or
anything else related to the problem below. or just what is the point
behind this behaviour?


*PHP 4*

how can i check if a method is called statically when called from inside
another object? (without debug_bactrace())

class foo
{
    function bar()
    {
        if ( isset( $this ) )
        {
            return 'not static';
        }
        return 'static';
    }

    function bar2() { foo::bar(); }
}


// returns 'static'
echo foo::bar();

// returns 'not static' but should be 'static'
$foo = new foo;
echo $foo->bar2();


*PHP 5*

and btw. does anyone know why it is not good to let one function handle
both methods of calling (static and not static) as in PHP 5 you will get
notices if called wrong - but PHP doesnt support multiple
function-definitions like:

class foo
{
    static function bar()
    {
        return ANY_DEFAULT_VALUE;
    }

    function bar()
    {
        return $this->value;
    }
}

or


class foo
{
    static function bar( $param )
    {
        return $param;
    }

    function bar()
    {
        return $this->param;
    }
}


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to