Skip to content
Quiz · Errors and exceptions · lesson 5 of 8

Quiz — catch (Exception) and an Error

Question 1 of 2

What happens when you run this program?

PHP
<?php

function safeDiv(int $a, int $b): string
{
    try {
        return (string) intdiv($a, $b);
    } catch (Exception $e) {
        return 'caught';
    }
}

echo safeDiv(6, 3), ' ', safeDiv(1, 0), "\n";