Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: Implement a Custom Exception | Custom Exceptions and Advanced Handling
/
PHP Error Handling and Exceptions
Sección 2. Capítulo 2
single

single

bookChallenge: Implement a Custom Exception

Desliza para mostrar el menú

Tarea

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.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 2
single

single

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt