<?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();
OtherClass::myFunc();
?>
Fatal error: Uncaught Error: Non-static method OtherClass::myFunc() cannot be called statically in /in/UdF8v:21
Stack trace:
#0 {main}
thrown in /in/UdF8v on line 21
Process exited with code 255.
Deprecated: Non-static method OtherClass::myFunc() should not be called statically in /in/UdF8v on line 21
Deprecated: Non-static method MyClass::myFunc() should not be called statically in /in/UdF8v on line 15
MyClass::myFunc()
OtherClass::myFunc()
Strict Standards: Non-static method OtherClass::myFunc() should not be called statically in /in/UdF8v on line 21
Strict Standards: Non-static method MyClass::myFunc() should not be called statically in /in/UdF8v on line 15
MyClass::myFunc()
OtherClass::myFunc()
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/UdF8v on line 4
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/UdF8v on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/UdF8v on line 4
Process exited with code 255.