error code php code example

Example 1: php show errors

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Example 2: php error

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

Example 3: How do I get PHP errors to display

//PHP functions
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

//.htaccess
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag log_errors on
php_value error_log  /home/path/public_html/domain/PHP_errors.log

Example 4: report simple error in php

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

Example 5: error php

// how to display php errors on your browser : 
// first step, create an error function : 

$errors = array();

// now you have just to insert the function like this : 

if (........){
  $errors['the_name_of_the_error']='the error message';
}

// example : 
// we want to display an error when the user does not correctly fill, 
// in the 'password' box when registering on your website : 

if(empty($_POST['password']) ||
   $_POST['password'] != $_POST['password_confirm']){
	$errors['errors']= "You must enter a valid password";
}

Tags:

Php Example