fork download
  1. <?php
  2.  
  3. class MyClass
  4. {
  5. protected $prop1;
  6.  
  7. public function __construct($str = substr('hello', 0, 3))
  8. {
  9. echo "$str\n";
  10. echo $this->foo1() . "\n";
  11. echo self::foo2() . "\n";
  12. echo $this->prop1 . "\n";
  13. }
  14.  
  15. protected function foo1()
  16. {
  17. return 2 + 2;
  18. }
  19.  
  20. protected function foo2()
  21. {
  22. return 3 + 3;
  23. }
  24.  
  25. public static function foo3()
  26. {
  27. return 'Hello world.';
  28. }
  29. }
  30.  
  31. $obj = new MyClass();
Runtime error #stdin #stdout #stderr 0.02s 24448KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Parse error:  syntax error, unexpected '(', expecting ')' in /home/z7XxKT/prog.php on line 7