Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

Main types of errors in PHP

 What are the main error types in PHP and how do they differ?


There are three basic types of run time errors in PHP:

  • Notices – Simple, non-critical errors that are occurred during the script execution. An example of a Notice would be accessing an undefined variable.
  • Warnings – more important errors than Notices, however the scripts continue the execution. An example would be include() a file that does not exist.
  • Fatal – This type of error causes a termination of the script execution when it occurs. An example of a Fatal error would be accessing a property of a non-existent object or require() a non-existent file.

Understanding the error types is very important as they help developers understand what is going on during the development, and what to look out for during debugging.


PHP define() Function


The define() function defines a constant.
You can define a constant by using the define()-function.
You can get the value of a constant by simply specifying its name. Unlike with variables, you should not prepend a constant with a $.

Syntax
define(name,value,case_insensitive)

Parameters

  1. name Required.Specifies the name of the constant
  2. value Required.Specifies the value of the constant
  3. case_insensitive Optional.Specifies whether the constant name should be case-insensitive.
    TRUE – Case-insensitive / FALSE – Default. Case-sensitive

Example #1

<?php
define("FOO", "Hello world.");
echo FOO; // outputs "Hello world."
echo Foo; // outputs "Foo" and issues a notice.
?>

Example #2

<?php
define("FOO", "Hello world.",TRUE);
echo FOO; // outputs "Hello world."
echo Foo; // outputs "Hello world."
?>

If you have any query or suggestions, feel free to ask me via the comment section below.

must watch some other topics :

cake PHP training institute
cake PHP training course
cake php training online


Post a Comment

0 Comments