<?php
class IsNullException extends Exception { }
class IsEmptyException extends Exception { }
function throwWhenNullOrEmpty($list)
{
if (is_null($list)) {
throw new IsNullException();
}
if (count($list) == 0) {
throw new IsEmptyException();
}
}
try {
$list = array();
throwWhenNullOrEmpty($list);
}
catch (IsNullException $e) {
echo "list is not specified";
}
catch (IsEmptyException $e) {
echo "list is empty";
}