Error Handling Mechanism in PHP


Error handling mechanism is too important for the web application to display the error message if the file doesn’t exist .
Error handling mechanism refers to the mechanism that indicates 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 the folder ) read the file.



Support Us - Subscribe Now

Recommended Posts:-

Previous Posts:-

Shop Items:-


Integrate PayPal payment gateway in PHP with MYSQL database | PHP scripts

$14



Integrate Payumoney payment gateway in PHP website | Source Scripts

$14



Complete Blog CMS system in PHP with MYSQL database | PHP scripts

$18







free instagram followers free instagram likes
escort istanbul
escort mersin
deutsche escort