fork download
  1. <?php
  2.  
  3. class ME {
  4. public static function staticMethod() {
  5. echo 'Derp!';
  6. }
  7.  
  8. public function yarr() {
  9. $this::staticMethod();
  10. }
  11.  
  12. public function hurr() {
  13. self::staticMethod();
  14. }
  15.  
  16. public static function durr() {
  17. $this::staticMethod();
  18. }
  19.  
  20. }
  21.  
  22.  
  23. $x = new ME();
  24.  
  25. $x->yarr();
  26.  
  27. echo "\n";
  28.  
  29. $x->hurr();
  30.  
  31. echo "\n";
  32.  
  33. ME::durr();
Runtime error #stdin #stdout #stderr 0.02s 23588KB
stdin
Standard input is empty
stdout
Derp!
Derp!
stderr
PHP Fatal error:  Uncaught Error: Using $this when not in object context in /home/VboCmE/prog.php:17
Stack trace:
#0 /home/VboCmE/prog.php(33): ME::durr()
#1 {main}
  thrown in /home/VboCmE/prog.php on line 17