Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: Implement a Custom Exception | Custom Exceptions and Advanced Handling
Practice
Projects
Quizzes & Challenges
Quizze
Challenges
/
PHP Error Handling and Exceptions
Abschnitt 2. Kapitel 2
single

single

bookChallenge: Implement a Custom Exception

Swipe um das Menü anzuzeigen

Aufgabe

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.

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 2
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

some-alt