Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Catch type errors in PHP 7
<?php
declare(strict_types=1);
function double(int $argument):int {
return $argument*2;
}
try {
var_dump(double("3"));
} catch (TypeError $e) {
echo "A type error occured: ".$e->getMessage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.