downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

InvalidArgumentException> <BadMethodCallException
[edit] Last updated: Fri, 23 Nov 2012

view this page in

The DomainException class

(PHP 5 >= 5.1.0)

Introduction

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

Class synopsis

DomainException extends LogicException {
/* Inherited methods */
final public string Exception::getMessage ( void )
final public Exception Exception::getPrevious ( void )
final public mixed Exception::getCode ( void )
final public string Exception::getFile ( void )
final public int Exception::getLine ( void )
final public array Exception::getTrace ( void )
final public string Exception::getTraceAsString ( void )
public string Exception::__toString ( void )
final private void Exception::__clone ( void )
}


add a note add a note User Contributed Notes DomainException
mateusz dot charytoniuk at gmail dot com 20-Oct-2011 12:45
<?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);
}
?>
johnny dot bojowkarz at gmail dot com 19-Jul-2011 03:27
<?php
function divide($dividend, $divisor)
{
  if(
$divisor == 0) {
    throw new \
DomainException(
     
'Zero does not belong to the domain of this functions.'
   
);
  }
  return
$dividend / $divisor;
}
?>

<?php
function logarithm($argument, $base)
{
  if(
$base <= 0 || $base == 1) {
    throw new \
DomainException(
     
'Specified base does not belong to the domain of this function.'
   
);
  }
  if(
$argument <= 0) {
    throw new \
DomainException(
     
'Specified argument does not belong to the domain of this function.'
   
);
  }
  return
log($argument, $base);
}
?>

 
show source | credits | sitemap | contact | advertising | mirror sites