<?php
class MyClass
{
protected function myFunc() {
echo "MyClass::myFunc()\n";
}
}
class OtherClass extends MyClass
{
// Override parent's definition
public function myFunc()
{
// But still call the parent function
parent::myFunc();
echo "OtherClass::myFunc()\n";
}
}
$class = new OtherClass();
$class::myFunc();
?>
Fatal error: Uncaught Error: Non-static method OtherClass::myFunc() cannot be called statically in /in/ioZUE:21
Stack trace:
#0 {main}
thrown in /in/ioZUE on line 21
Process exited with code 255.
Deprecated: Non-static method OtherClass::myFunc() should not be called statically in /in/ioZUE on line 21
Deprecated: Non-static method MyClass::myFunc() should not be called statically in /in/ioZUE on line 15
MyClass::myFunc()
OtherClass::myFunc()
Strict Standards: Non-static method OtherClass::myFunc() should not be called statically in /in/ioZUE on line 21
Strict Standards: Non-static method MyClass::myFunc() should not be called statically in /in/ioZUE on line 15
MyClass::myFunc()
OtherClass::myFunc()