arqam
arqam

Reputation: 3809

How to see the errors in php code in chrome

My php code is in the hostgator server and since I have to write a few scripts I don't have to install the wamp/lamp server.

I did a bit digging and found extensions namely PHP console. I added it and tested once, it showed me the line number of the errror.

But after a few hours when I tested the extension it is not working anymore for the same script and the same error.

I also tried another popular extension called Xdebug helper. But that also seems to be not working.

To test I have removed a semicolon in my working script and the link is : http://arqamahmad.com/music_app/getmusic.php

PS : I am using a shared hostgator server and I have done my research on the .htaccess and php.ini files. Nothing is helpful. The PHP console extension was the best but there seems to be some problem to that.

Answer : I had to add a php.ini file inside public_http making allowing the php debug mode on then only it the extensions work.

Upvotes: 0

Views: 8556

Answers (3)

Anas
Anas

Reputation: 61

Step 1: Simply go to your server which you have installed (XXAMP, WAMP, MAMP, LAMP) search for php.ini

Step 2: Open this file in any text editor and search for display_errors and now set it to "on" like this display_errors = On

Step 3: Restart your server

Boom :)

Upvotes: 0

Andreas Wolf
Andreas Wolf

Reputation: 1065

For Firefox, there is FirePHP (http://www.firephp.org/) in combination with Firebug. There is a similar extension for Chrome, but I haven’t tested that (https://github.com/itsgoingd/clockwork-chrome).

The general thing is that you need to somehow transfer your error messages from PHP back to the client. If you don’t want to use a browser extension for that, you can also use an approach chosen by many frameworks (e.g. Symfony): add an admin module in your page, where the error messages are displayed (you need to intercept errors on the servers for that, by registering a custom error handler).

Edit: This of course requires PHP to output error messages at all, which depends on (among others) the php.ini settings like error_reporting, which need to be set to a level that the errors you desire for reporting will trigger the error handler functions.

Concerning your remark about Xdebug: to use Xdebug helper, Xdebug (a PHP extension for debugging) needs to be available on the server, which it usually is not on production systems.

Upvotes: 3

RaitzeR
RaitzeR

Reputation: 1

Since php is executed on the server side, no browser add-on will help you. You need to add a few lines of code to the php file to show the errors.

Here's a link for you: https://stackoverflow.com/a/21429652/6735510

Upvotes: 0

Related Questions