PHP 5.5.17 is available

The DomainException class

(PHP 5 >= 5.1.0)

Introdução

Exception thrown if a value does not adhere to a defined valid data domain.

Sinopse da classe

DomainException extends LogicException {
/* Propriedades herdadas */
protected string $message ;
private string $string ;
protected int $code ;
protected string $file ;
protected int $line ;
private array $trace ;
/* Métodos herdados */
final public string Exception::getMessage ( void )
final public int Exception::getCode ( void )
final public string Exception::getFile ( void )
final public string Exception::getLine ( void )
final public array Exception::getTrace ( void )
final public string Exception::getTraceAsString ( void )
public string Exception::__toString ( void )
final private string Exception::__clone ( void )
}
add a note add a note

User Contributed Notes 2 notes

up
17
mateusz dot charytoniuk at gmail dot com
2 years ago
<?php
function renderImage($imageResource, $imageType)
{
  switch (
$imageType) {
  case
'jpg':
  case
'jpeg':
   
header('Content-type: image/jpeg');
   
imagejpeg($imageResource);
    break;
  case
'png':
   
header('Content-type: image/png');
   
imagepng($imageResource);
    break;
  default:
    throw new
DomainException('Unknown image type: ' . $imageType);
    break;
  }
 
imagedestroy($imageResource);
}
?>
up
1
chmielewski dot thomas at gmail dot com
20 days ago
<?php

function divide($divident, $divisor) {
    if(!
is_numeric($divident) || !is_numeric($divisor)) {
        throw new
InvalidArgumentException("Function accepts only numeric values");
    }
    if(
$divisor == 0) {
        throw new
DomainException("Divisor must not be zero");
    }
    return
$divident / $divisor;
}
To Top