Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Handle Specific Exception Types | Understanding PHP Errors and Basic Exception Handling
Practice
Projects
Quizzes & Challenges
Вікторини
Challenges
/
PHP Error Handling and Exceptions
Секція 1. Розділ 6
single

single

bookChallenge: 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 InvalidArgumentException if the argument is not an integer.
  • Throw a RuntimeException if the argument is a negative integer.
  • Return the argument multiplied by 2 for valid input.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 6
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

some-alt