I read a book about PHP when I came across some weird piece of code:
class Employee {
public function show() {
echo "show launched\n";
}
}
Employee::show();
I came from C ++, so I was going to bet that this code would not work. That is why I tested it.
And it worked, showing "show running" (omg, am I drinking?)!
It seems to violate the concept that a class method can be called without instantiating the class.
- What is the meaning of a static identifier in classes?
- Are all public functions static too? Really, what am I missing?
Thanks in advance.
Addition:
Just a notice.
I found that in this book . Pages 178-179 and are given as a correct example (if I'm right)