I need to implement the square brackets (array operator) in a static PHP class.
The main goal is to have class calls like this at the end :
MyStaticClass[ $something ] = $somethingElse ;
$SomeVar = MyStaticClass[ $something ] ;
I know that this is an heresy, but I really need it…
Any idea ?
I’m wondering if a static call to such an operator is possible, since I found nothing on the web.
Thanks for every help 🙂
[]can not be overloaded only variable and methodsSample Class
Calling it directly
You can also use
Both of them would Output
In PHP 5.4