Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Implement a Custom Exception | Custom Exceptions and Advanced Handling
PHP Error Handling and Exceptions
Секція 2. Розділ 2
single

single

bookChallenge: Implement a Custom Exception

Свайпніть щоб показати меню

Завдання

Swipe to start coding

In this task, you will define a custom exception class and use it to handle invalid user input in a registration form scenario. This will help you practice creating your own exception types and using them to manage errors in a more meaningful way.

  • Define a custom exception class named InvalidRegistrationException that extends the built-in Exception class.
  • Implement the validateRegistration function so that it throws an InvalidRegistrationException if the username is empty.
  • Make the function throw an InvalidRegistrationException if the password is less than 6 characters long.
  • If both checks pass, the function should return a success message containing the username.

Рішення

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

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

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

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

single

Запитати АІ

expand

Запитати АІ

ChatGPT

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

some-alt