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

single

bookChallenge: Handle Specific Exception Types

Veeg om het menu te tonen

Taak

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.

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 6
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

some-alt