Секція 1. Розділ 6
single
Challenge: Handle Specific Exception Types
Свайпніть щоб показати меню
Завдання
Swipe to start coding
Practice using multiple catch blocks to handle specific exception types in PHP. Build on your understanding of built-in exception classes by writing a function that throws different exceptions based on input.
- Throw an
InvalidArgumentExceptionif the argument is not an integer. - Throw a
RuntimeExceptionif the argument is a negative integer. - Return the argument multiplied by 2 for valid input.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 1. Розділ 6
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат