<?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";
}
}
}
// this will print '$this is defined (A)'
$a = new A();
$a->foo();
// what does this print?
A::foo();
$this is defined (A)
Fatal error: Uncaught Error: Non-static method A::foo() cannot be called statically in /in/VW0bc:21
Stack trace:
#0 {main}
thrown in /in/VW0bc on line 21
Process exited with code 255.