codescracker


php

PHP Error Handling



« Previous Tutorial Next Tutorial »


Error handling plays an important role, if you are going to make a professional web applications using PHP.

While writing your PHP program you should check all the possible error condition before going ahead and take appropriate action when required

Go through the following example without having /tmp/test.xt file and with this file

<?php
	if(!file_exists("/tmp/test.txt"))
	{
		die("File not found");
	}
	else
	{
		$file=fopen("/tmp/test.txt","r");
		print "File Opened successfully";
	}
	// Test of the code here
?>

Here is the general form to define a custom error in PHP:

error_function(error_level,error_message, error_file,error_line,error_context);

Here is the explanation of the above parameters used in defining a custom error in PHP:


« Previous Tutorial Next Tutorial »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test