Search code examples
phpjavascriptdebuggingwebphpstorm

where to find PHP output / log


I am a beginner web developer, specifically, with PHP and some front-end techniques (HTML,CSS,JS/JQuery). I found in some situations, it's quite difficult find the bugs in PHP code. Here is one of examples:

In a HTML page, I use JQuery to submit (with post) a form to a PHP file for back-end transaction. Since I am using JQuery, the page will not be redirected to the PHP page, so if the PHP code has some bugs (even some stupid syntax / SQL errors), it can be hardly to detect them when we test them with a normal navigator.

My question is : if I use echo in the PHP page in the above case, where will the output reside ? I think there should exist some log files for all these sorts of output. What's more, if there are some bugs in the JavaScript, are there any tricks to quickly locate the bugs ?

PS: I am using PHPStorm as IDE under MAC OS.


Solution

  • When you are running AJAX (it sounds that way judging from your question), all jQuery is doing is request the page 'for you'. So instead that you can directly see the output, jQuery will 'catch' it for you. An AJAX request is nothing more than a normal HTTP request, just in the background so you won't see it.

    Therefore; when you 'echo' something, it will just be handled by jQuery and therefore sent to your browser.

    There are some tools like firebug that allow you to look into the request and response from your ajax messages, and thus displaying possible errors or different output too. It's an all-around debugger, so you can also see your rendered HTML and/or JavaScript errors.