1ini_set('display_errors', '1');
2ini_set('display_startup_errors', '1');
3error_reporting(E_ALL);
1ini_set("log_errors", 1); // Enable error logging
2ini_set("error_log", "/tmp/php-error.log"); // set error path
3error_log( "Hello, errors!" ); // log a test error
4
1// Php Error Log
2error_log("Error message");
3
4// Log and Array
5error_log( print_r( [
6 __METHOD__,
7 'error_key_1' => 'error_value'
8] ) );
1// how to display php errors on your browser :
2// first step, create an error function :
3
4$errors = array();
5
6// now you have just to insert the function like this :
7
8if (........){
9 $errors['the_name_of_the_error']='the error message';
10}
11
12// example :
13// we want to display an error when the user does not correctly fill,
14// in the 'password' box when registering on your website :
15
16if(empty($_POST['password']) ||
17 $_POST['password'] != $_POST['password_confirm']){
18 $errors['errors']= "You must enter a valid password";
19}