Request a Call back


Learn Error Handling in Programs through PHP Training

One should know error handling in programs to become an effective PHP developer. PHP training can give the learner the best knowledge of error handling through practical learning methods conducted in PHP classes under the guidance of experts.

PHP or Hypertext Preprocessor is a popular server-side scripting technology used for building dynamic websites. Just as the programs developed in any other programming language, bugs or errors may arise in PHP programs too and to handle them one should have good knowledge of how these errors arise and what are the effective ways to handle them. In order to be a successful PHP developer, one should have good command over errors and error handling. Hence, joining PHP training course at a good PHP coaching institute would be a better way to get knowledge of the programming language. One can learn error handling in programs in a much effective way through practical learning conducted in PHP classes under the guidance of experts.

The first requirement of a developer to debug the programs is to understand the cause of the errors. The better is the understanding of the error cause, the lesser would be the time required to fix the errors by the developer. The errors in PHP are usually of three types – syntactical, logical; and run time errors.

Errors in PHP

  • Syntactical errors are those resulting from improper syntax. For example it may the something like left out braces or a missing semi colon etc.
  • These kinds of bugs will not allow the php script to execute while this is not the case with the run time errors which do not allow the program the desired output. These do not arise at compile time and hence program will be compiled with these errors but will not show the required output.
  • Last but not the least and most difficult at few times to solve are the logical errors. These errors do not report and do not stop the script from running but cause failure to produce proper output.

Apart from these there are a few other errors that are usually seen arising out of PHP programs like

  • HTML or display errors that will result in display of blank page on program execution.
  • The misspelled or improper capitalized variable name, or inappropriate variable type or scope defined for the function parameters.
  • A misspelled function name during function calling may result in error “call to undefined function”.
  • There might re-declaration of the same function more than once. In this case program shows error as there could not be two functions with same name in a PHP program.

Error Handling in PHP

Errors can be handled easily in PHP with the help of following techniques.

  1. @operator:  @operator can be used for expressions, function calls or mathematical operations but not before the conditionals, loops, function definitions etc.

For example:


@include (‘script_name.php’); //in case you do not want to see the “division by zero” error

$num = @ ($x/$y);


  1. In case of external data received through POST method or from forms or URLs, it is better to check whether the value exists or not, in order to easily understand the problem and where it is and to avoid the error messages to display.

For Example:


if (isset($_POST[‘var_name’])){

$var_name1 = $_POST[‘var_name’];



echo “Did not get the data for var_name”;



In the above program the condition if() will be executed if the POST method receives appropriate value and if it does not receive the value then the statement in else will be displayed making the user clearly understand about the error.

  1. One can also make error to be triggered upon enterance of wrong input. This will give user better understanding about the errors.

For Example:


if (isset($_POST[‘Name’])) {

trigger_error(‘You must add a number not the name’);



This way one can clearly understand the where the errors are arising in the program and hence, can easily handle the errors in shorter time duration. To get this understanding of programming in a better way, one should join PHP training classes in order to get hands-on programming experience under the guidance of experts who can guide the learners about errors and ways to solve them.

Leave a Reply

Your email address will not be published.

Leave a Reply

Your email address will not be published. Required fields are marked *

Need Answers


Our Counsellors can Answer Any Queries.

 Just Request a Call

Thank you

Calling you Soon