<?php
function checkValue($value) {
if ($value < 0) {
throw new Exception("Value must be non-negative");
}
return $value;
}
// Example usage:
try {
$result = checkValue(-5);
echo "Result: $result";
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>