Basic
Advanced
Examples
PHP 8 - Error Handling
Last modified: April 02, 2022The try...catch Statement
function readFile($filePath)
{
if($filePath == '')
{
throw new Exception("file not found");
}
}
try
{
readFile("/a.txt");
}
catch{
echo "Unable to find the file";
}