<?php
class A {
public static function classMethod() {
echo "class method\n";
}
public function instanceMethod() {
echo "instance method\n";
}
public function inspect() {
self::classMethod();
self::instanceMethod();
}
}
$a = new A();
$a->classMethod();
$a->instanceMethod();
echo "--------------------------\n";
$a->inspect();
echo "--------------------------\n";
A::classMethod();
A::instanceMethod();
/**
*
* class method
* instance method
* --------------------------
* class method
* instance method
* --------------------------
* class method
*
* Deprecated: Non-static method A::instanceMethod() should not be called statically
* instance method
* PHP Deprecated: Non-static method A::instanceMethod() should not be called statically
*
* --------------------------
*
* 流石はPHPといったところでしょうか? instanceMethod()は、instance を作らないとアクセスできないようですが、
* それ以外は何でもありです。
*/