-1

I've just started to learning some coding. I've learn't some HTML, CSS, and JS so far. I'm currently working on a small PHP file, and I'm wondering where I go to debug PHP errors.

I'm uploading the small site (which is html5, css3, bootstrap and jQuery) to a HostGator server, so I have little to no control of that.

With JS I've been using the Firefox Console, and CSS I find the Inspector to be very good. Is there something similar for PHP?

My understanding is that PHP is all done on the server, but can I view errors in my PHP in my Browser? Or, do hosts (like HostGator) provide a console type interface, that I haven't been able to find?

Herohtar
  • 5,347
  • 4
  • 31
  • 41
SimonB
  • 325
  • 4
  • 13
  • 2
    Possible duplicate of [How do I get PHP errors to display?](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) –  Jan 05 '19 at 02:41

3 Answers3

1

login to SSH, for how to read here. write the following command in your SSH client/console

tail -f /path/to/error.log

it will give you live report but if you still not able to see the error, you need to add this lines to php.ini, or read here for how to

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ewwink
  • 18,382
  • 2
  • 44
  • 54
0

Put this at the beginning of your php code:

error_reporting(E_ALL);
ini_set('display_errors', 1);
EvE
  • 734
  • 3
  • 13
0

PHP is a server side language so you can't use the browser console like JavaScript. However, depending on what Editor your using, you can set up something like xDebug - https://xdebug.org/index.php, which will allow you to pause PHP during execution, see variable values, etc...

You can also use var_dump() http://php.net/manual/en/function.var-dump.php, to dump out values, etc...

cmac
  • 3,123
  • 6
  • 36
  • 49