PHP: Error Handling mechanism:-

Error handling mechanism is to important for web application to display the a error message if file doesn’t exist .
Error handling mechanism refers the mechanism that indicate this error to the end user .


Example

<?php

if (!file_exists("testfile.txt"))
{
	die("File not found");//die used for error handling .
}
	else
	{
      $file = readfile("testfile.txt");
	}
echo $file;
?>
Run

In Detailed

	


if (condition for check the file if not exist)
{
	die("File not fount");//die used for error handling .
}
	else
	{
      Else file exist read it .
	}
echo $file;


Here you can see that if the file does not exist the statement"File not fount" will print and else(if the file exists in folder ) read the file.