What can I do to make my PHP web application more complex?

What can I do to make my PHP web application more noisy?

I use the MVC pattern, and often when classes fail to load or fail, they do so without error.

+2


a source to share


6 answers


<?php
error_reporting( E_ALL );
ini_set( 'display_errors', '1' );
ini_set( 'log_errors', '1' );

function error_handler($errno, $errstr, $errfile, $errline) {
  system('/usr/bin/mplayer /home/user/music/Moras_Modern_Rhythmists/Mr._Ghost_Goes_to_Town.mp3', $retval);
  return true;
}

set_error_handler( "error_handler" );
?>

      



+9


a source


Depending on the level of your bug reporting, you might try to raise it via .htaccess.



php_value display_errors 1
php_value error_reporting 2147483647 

      

+1


a source


Use require_once method to load files instead of include.

I think you are asking, right?

0


a source


If you are testing, check if the display_errors property is enabled in your php.ini settings.

0


a source


<?  ini_set("Melodramatic", "true"); ?>

      

0


a source


Easy answer: die('A fatal error occurred')

In a PHP application that I wrote, I came up with a convention for using a variable or class member with a name $err_msg

initially set to null. When an error occurs, set it to a human readable string. When errors need to be checked, mark $err_msg

and place it on the display for the end user. If it's an AJAX call, echo $err_msg

on failure, echo 'OK'

on success.

In my case, I wrote a simple jQuery based status window that can display busy and error indicators. When the AJAX call returns an error, I make the status window fade out in red and display the error message. It's pretty good and even.

0


a source







All Articles