Sección 1. Capítulo 6
single
Challenge: Handle Specific Exception Types
Desliza para mostrar el menú
Tarea
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
InvalidArgumentExceptionif the argument is not an integer. - Throw a
RuntimeExceptionif the argument is a negative integer. - Return the argument multiplied by 2 for valid input.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 1. Capítulo 6
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla