1

I'm writing php since almost six months now.

I asked myself if there is any way to check for errors in php files or false behavior if the php function in launched from an html file.

Let's assume I'm running a login.html file on my webserver. The function needed to login is executed within a block inside the html file.

The used php function is inside an external php file (functions.php).

If i got any errors within my php file, my errorhandler class won't catch it (maybe a fatal error).

Is there any way to see this in some kind of log?

The only thing I see is the failed login attempt on my html site.

Any feedback is greatly appreciated! Thank you guys for this great community (:

TCMPK
  • 13
  • 2

2 Answers2

3

Adding these two lines to the start of your php script will turn on php error reporting. Your php errors will then display in the browser.

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

You can also turn php error reporting on from within the php.ini file.

To instead send the errors to a log file, you need to follow these instructions on specifying a log file. The instructions say to add the following two lines to your php script:

    ini_set("log_errors", 1);
    ini_set("error_log", "/tmp/php-error.log");

Then you can monitor the file with the tail command:

    tail -f /tmp/php-error.log
Community
  • 1
  • 1
Reflexorozy
  • 320
  • 2
  • 9
0

Before you run the login, you right click -> inspect element, choose Network tab (or similar depending on the browser you use), and check the requests being made there.

If your script allows to display errors ( see Reflexorozy comment ), you should have the error there in the tabs of that request.

Cornel Raiu
  • 1,592
  • 18
  • 22