I would like to use PHP's __toString()
method in a static manner, like so:
class MyClass {
public static function __toString() {
echo 'Hello, I am MyClass!';
}
}
echo (string) MyClass;
Unfortunately though __toString()
cannot be a static method. It would be great if this was possible though, so my question is: Is this something reasonable to propose as a feature request to PHP devs? If not, how can we achieve this kind of functionality as closely to what my example describes as realistically possible?