PHP 8.5.0 Alpha 4 available for testing

Voting

: six plus two?
(Example: nine)

The Note You're Voting On

Jakub Adamczyk
8 years ago
I see this in this way:
By definiton, OutOfRangeException should be use to when potential problem is logical. This (OutOfBoundsException) is for runtime, so it's perfect for catching errors which occur because of bad result from database and simillar.

Example of using OutOfBoundSException (see also note in "OutOfRangeException class" article):

<?php
class HandleApplication {
public function
__construct($_POST) {
if(!isset(
$_POST['secretCode'])
throw new
OutOfBoundsException('Application hasn't sent secret code for authenticate');
}

<< Back to user notes page

To Top