Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: Apply Safe Execution Patterns | Validation Flows and Safe Execution Patterns
PHP Error Handling and Exceptions
Sección 3. Capítulo 4
single

single

bookChallenge: Apply Safe Execution Patterns

Desliza para mostrar el menú

Tarea

Swipe to start coding

Refactor the divideNumbers function to use safe execution patterns for division in PHP.

  • Validate that both numerator and denominator are numbers.
  • If either argument is not a number, throw an InvalidArgumentException.
  • If denominator is zero, throw a DivisionByZeroError.
  • If validation passes, return the result of dividing numerator by denominator.

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 3. Capítulo 4
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