<?php
class A {
function example() {
echo "I am the original function A::example().<br />\n";
}
}
class B extends A {
function example() {
echo "I am the redefined function B::example().<br />\n";
A::example();
}
}
// there is no object of class A.
// this will print
// I am the original function A::example().<br />
A::example();
// create an object of class B.
$b = new B;
// this will print
// I am the redefined function B::example().<br />
// I am the original function A::example().<br />
$b->example();
Fatal error: Uncaught Error: Non-static method A::example() cannot be called statically in /in/CPSrO:18
Stack trace:
#0 {main}
thrown in /in/CPSrO on line 18
Process exited with code 255.
Deprecated: Non-static method A::example() should not be called statically in /in/CPSrO on line 18
I am the original function A::example().<br />
I am the redefined function B::example().<br />
I am the original function A::example().<br />
Strict Standards: Non-static method A::example() should not be called statically in /in/CPSrO on line 18
I am the original function A::example().<br />
I am the redefined function B::example().<br />
I am the original function A::example().<br />