在哪里可以找到PHP输出/日志

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.

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.

To answer your question specifically; the output from the echo in your example will be in the response to the post request. Normally that would be the page reload but in an ajax request (as you stated) you don't get that.

Use a browser developer tool like the Inspector in chrome or firebug in Firefox to allow you to see the Ajax responses from you post request

You can also log the responses using the console.log Javascript method, in the success section of your ajax

$(function() {

    $.ajax({
        // snip
        success: function(response) {
            console.log(response);
        }
    });

When you are developing the PHP pages, where the ajax is requesting from, make them first to output the result on the screen, test them, then make the jquery request, when you are sure they are outputting the proper thing

use "Firebug" console for firefox, "Firebug lite" for chrome or press "F12" for IE. You will see the console. there you can see the ongoing ajax request and see the response.

If you are using PHPstorm i suggest you to take a look at Xdebug. You have to enable Xdebug module from your server and you can manage php with breakpoints and varibles Watches.