0

This is a common question for all web developers , i wanted to know about some tools for Chrome browser to find PHP based errors from the browser itself.

Sometimes When we open a page done in php shows blank screen with out any error message or warning.It is is very hard to go through the code line by line if no error or warning message in the screen.

I question is do we have any option in **

Chrome browser

** to check the php error?

Hari kris
  • 49
  • 13
  • 1
    Check the error logs on the server. – Blake Sep 20 '16 at 15:06
  • Edit php.ini or just `error_reporting(E_ALL); ini_set('display_errors', '1');` – AbraCadaver Sep 20 '16 at 15:07
  • Possible duplicate of [PHP errors NOT being displayed in the browser \[Ubuntu 10.10\]](http://stackoverflow.com/questions/5050426/php-errors-not-being-displayed-in-the-browser-ubuntu-10-10) – SOFe Sep 20 '16 at 17:49

2 Answers2

1

You can enable error_reporting try adding the following to your code.

I've copied this code from the PHP Website

// Turn off all error reporting
error_reporting(0);

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

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);

// Report all PHP errors (see changelog)
error_reporting(E_ALL);

// Report all PHP errors
error_reporting(-1);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

Just remove the ones you don't need. For example this is all I have inside my file

// Debug - Development Mode
error_reporting(E_ALL);
ini_set("display_errors", 1);

I did a quick Google Search and came back with this for Chrome Report extension: https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef?hl=en

Stephen
  • 515
  • 1
  • 14
  • 31
1

Nope you can't check it in Chrome. As you said there is a blank screen so there is nothing returned to the browser, except most probably few headers.

You have to access the server and check the logs. Depending on the way PHP is running on that server and what webserver is used and how is the setup made the file containing PHP errors may be located in different locations.

Please keep in mind that errors, stack trace output etc. contains a lot of information which could be used to attack against the system so it's not recommended to output such information in Production systems.

jakub wrona
  • 2,212
  • 17
  • 17
  • Thanks for the answer. I faced the same question during a job interview ! From the time itself i searched for the same ,but i couldn't! :) – Hari kris Sep 20 '16 at 15:17