3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class DataMapper { // 削除 public function delete(array $conditions): int { // 削除に失敗して例外が発生したと仮定 throw new RangeException('削除に失敗しました'); // 本来は削除に成功した行数を rowCount で得て返す return 1; } } class CommentMapper extends DataMapper { // コメント削除 public function destroyComment(int $comment_id): int { try { $conditions = ['id'=>$comment_id]; $rowCount = parent::delete($conditions); return $rowCount; } catch (Exception $e) { echo $e->getMessage(); } } } class CommentController { public function destroyAction(int $comment_id): void { $commentMapper = new CommentMapper(); $rowCount = $commentMapper->destroyComment($comment_id); var_dump($rowCount); } } $commentController = new CommentController(); $commentController->destroyAction(1);
Output for git.master_jit, git.master, rfc.property-hooks
削除に失敗しました Fatal error: Uncaught TypeError: CommentMapper::destroyComment(): Return value must be of type int, none returned in /in/i5lbv:26 Stack trace: #0 /in/i5lbv(34): CommentMapper->destroyComment(1) #1 /in/i5lbv(40): CommentController->destroyAction(1) #2 {main} thrown in /in/i5lbv on line 26
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
103.88 ms | 406 KiB | 5 Q