fork download
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. function increment(int $x): int
  6. {
  7. return $x + 1;
  8. }
  9.  
  10. echo increment('1'); // 2
Runtime error #stdin #stdout #stderr 0s 82560KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to increment() must be of the type integer, string given, called in /home/cEDQIM/prog.php on line 10 and defined in /home/cEDQIM/prog.php:5
Stack trace:
#0 /home/cEDQIM/prog.php(10): increment('1')
#1 {main}
  thrown in /home/cEDQIM/prog.php on line 5