Jump to content

static method and normal method declaration??


riddhi

Recommended Posts

<?php

class A

{

    function foo()

    {

        if (isset($this)) {

            echo '$this is defined (';

            echo get_class($this);

            echo ")\n";

        } else {

            echo "\$this is not defined.\n";

        }

    }

}

 

class B

{

    function bar()

    {

        A::foo();

    }

}

 

$a = new A();

$a->foo();

A::foo();

$b = new B();

$b->bar();

B::bar();

?>

 

 

In the above what does A::Foo() represents a static method?? is there no declaration difference between the static and the normal method.

The code above should produce all sorts of errors.

 

<?php

class A
{
    static function foo()
    {
        if (isset(self)) {
            echo 'self is defined (';
            echo get_class(self);
            echo ")\n";
        } else {
            echo "\self is not defined.\n";
        }
    }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.