Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Handle Specific Exception Types | Understanding PHP Errors and Basic Exception Handling
Practice
Projects
Quizzes & Challenges
Visat
Challenges
/
PHP Error Handling and Exceptions
Osio 1. Luku 6
single

single

bookChallenge: Handle Specific Exception Types

Pyyhkäise näyttääksesi valikon

Tehtävä

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 InvalidArgumentException if the argument is not an integer.
  • Throw a RuntimeException if the argument is a negative integer.
  • Return the argument multiplied by 2 for valid input.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 6
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

some-alt